Running a Discord bot on a Node.js VM. When started with node botStarter.js
, it stops once the SSH session ends. How can I ensure it remains running continuously?
hey try pm2, it’s the easiest method to keep your bot runing after ssh disconnect. i personally used it and it handles restarts and logs pretty well.
Based on my experience managing a Discord bot on production servers, an effective alternative to PM2 is to set up a systemd service. I created a unit file that directly executes my bot, which ensured that it automatically restarted after crashes or system reboots. This method decouples the bot from user sessions and offers detailed logging via journald for easier issue tracking. While it requires some initial configuration, the long-term reliability and integration with system management tools make it a robust choice.