Reputation: 19
So my discord bot would crash if someone did a wrong command. I did some googling and after I did some research I found pm2. I heard it could run "node ." automatically to start my bot if it crashed, but I don't know how to use it. Does anyone know how to use pm2?
Thanks in advance!
Upvotes: 1
Views: 5140
Reputation: 2675
Once you have PM2 started and your processes running through it, run
pm2 startup
to initialize the automatic startup. This command will save your current persistence but if you need to change it later you can run:
pm2 save
It simply starts back up where you saved it so make sure all the processes are in the state you want before doing this using
pm2 list
(this does not change the code or your apps data at the time of the save, just the running state).
Upvotes: 1
Reputation: 2722
Use npm or yarn to get app.
$ npm install pm2@latest -g
# or
$ yarn global add pm2
Then you can start procces with pm2 start name
cd main_file_folder_path
pm2 start app.js
List of process
$ pm2 list
stop process
$ pm2 stop 0
Restart process:
$ pm2 restart 0
Show info about process
$ pm2 show 0
Delete process
$ pm2 delete 0
Upvotes: 0