Keep Your Node.js Application Running 24/7
To keep a Node.js application running 24/7 on your VPS, you can use the screen command. Follow these steps:
1. Create a Screen Session
A screen session allows the bot to keep running even when you close the terminal. To start a new screen session, run:
Now, you're inside the new screen session. (You can replace PlexTickets with a name of your choice)
2. Start the Bot
Navigate to the folder where your application is installed:
(Replace
/path/to/plex-tickets
with the actual path, e.g.,/home/PlexTickets
)Start the application by running:
3. Detach from the Screen
Once the bot is running, you can safely detach from the screen session without stopping the bot. To do this:
Press
CTRL + A
, then pressD (All at the same time)
You will return to the regular terminal, and the bot will continue running in the background.
4. Reconnect to the Screen
If you ever need to access the bot or restart it, follow these steps:
List all active screen sessions:
You’ll see a list of active screens, something like:
Reconnect to the screen session by running:
(Replace
<screen_id>
with the actual ID, e.g.,12345
)
5. Stop or Restart the Application
To stop the application, simply press
CTRL + C
inside the screen session.To restart, run the
node .
command again.
The application will stop if you restart or shut down the VPS. After rebooting, repeat the steps to start the bot. Keep the VPS running to ensure the bot is active 24/7.
Last updated