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.
Note: Many modern Linux distros include SystemD, which you can use to set up a SystemD service instead of using PM2.
To start out with, ensure you have installed Node.js and NPM.
If you have node and npm installed, you can start running the following to install PM2:
With these commands done, your bot should be running in the background and should restart automatically on boot up and if MusicBot crashes.
At any point after this, if you would like to view logs, start, stop, or restart MusicBot, you can use the following commands: