When I restart the ubuntu server the node.js services in the server are not running in the background. I need to connect to the server and start the services whenever I restart the server.
CodePudding user response:
You need to use pm2 is a advanced process manager for production Node.js applications. Load balancer, logs facility, startup script, micro service management, at a glance.
With this you can run in background
CodePudding user response:
Use PM2.
To install PM2:
npm install -g pm2
To start a node.js process:
pm2 start -n "My task name" /path/to/node/script
To list process:
pm2 list
To restart manually a process (after update for example):
pm2 restart <id of process>
PM2 will handle restart automatically in some case, or you can also tell PM2 to restart node process if script change. And many other cool things.