I'm using codeship to autodeploy my nextjs app from github. My deployment script is as follows
ssh user@SERVER_IP 'cd projectfolder/; git checkout master; git pull; npm run build; pm2 delete app; pm2 start npm --name "app" -- start;'
If I don't delete the process first the app will be duplicated with the next push.
This config works fine, but I'm kinda not sure about that deleting thing, since I found that there is a cleaner command like startOrRestart that will start a new one or restart existing process with the same name. I couldn't get it working though.
It should be very easy with
pm2 restart appName, in your case you only need to runevery time you need to restart your application, given that you initially start your application with