I'm using PM2 to run a NodeJS app. Sometimes it's desirable to restart the app. Is there a way to do this from within the app, to avoid having to log into the server each time?
Would the simplest solution be to set PM2 to restart on changes in the app directory, then have the app touch a file? Or is there a way to interact with PM2 from within the app?
PM2 starts a process that ended, this means that if the process exits due to exception or regular exit, it will restart it.
So, just run this when ever needed
process.exit(0)