MusicBot logo MusicBot

This guide will assist you in installing PM2 to run MusicBot in the background of Linux and Mac, automatically restart it if it crashes, and at startup. To start out with, ensure you have installed Node.js and NPM. This guide also assumes you clones MusicBot in your home folder. If you didn’t, you’ll need to replace those commands with the path to your MusicBot folder. If you have node and npm installed, you can start running the following to install PM2:

npm install pm2@latest -g
cd ~/MusicBot
pm2 start run.py --name "MusicBot" --interpreter=python3
pm2 startup
pm2 save

With these commands done, your bot should be running in the background, should restart if it crashes, and should start whenever you start your system.

At any point after this, if you would like to view logs, start, stop, or restart MusicBot, you can use the following.

pm2 logs MusicBot      - View MusicBot logs
pm2 restart MusicBot   - Restart MusicBot
pm2 stop MusicBot      - Stop MusicBot
pm2 start MusicBot     - Start MusicBot