How to run a node.js application permanently ?
Using PM2 module:
- Installing module in project Directory:
npm install pm2 -g
- Start Your Node.js Application by pm2.
pm2 start [Your fileName]
- All processes listed up which are registered with pm2.
- We can also stop any process runs by pm2 stop command:
pm2 stop all pm2 stop [id number]
Using forever module
- Installing module in your project Directory:
npm install forever -g
- Start Your Node.js Application by forever module.
forever start [Your FileName]
- All processes listed up which are registered with forever
- We can also remove or stop any processes that are registered with forever using index (such as 0 in this case)
forever stopall forever stop [index]
So now your Application will be running permanently even after exiting the terminal or Application.