How to auto restart pm2 apps during file modifications

PM2 can automatically restart your application when a file is modified in the current directory or its sub-directories.

Watch function need to be enabled for this auto-restart. This can be enabled on starting the application using pm2.

#pm2 start app.js --watch

If we need to disable watch, use the following command.

#pm2 stop id --watch

Here id need to be replaced by the application pid.

That's all…

Leave a Reply

Your email address will not be published. Required fields are marked *