Node.js applications can be managed and restarted upon a rebooted with PM2, which is a process manager for Node.js applications.
To install the Node.jsmodule:
sudo npm install -g pm2
To start and daemonize any application:pm2 start application.js
Then to generate an automatically-configured startup script for your machine
pm2 startup
pm2 startup upstart [PM2] You have to run this command as root. Execute the following command: sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup upstart -u ...
Copy and paste the command.Once you have started all the Node.js applications you want to manage across server restarts or reboots.
pm2 save
and to remove it from startuppm2 unstartup
Same needs to be done after npm update or upgrade (unstartup then startup)
Init systems
- systemd: Ubuntu >= 16, CentOS >= 7, Arch, Debian >= 7
- upstart: Ubuntu <= 14
- launchd: Darwin, MacOSx
- openrc: Gentoo Linux, Arch Linux
- rcd: FreeBSD
- systemv: Centos 6, Amazon Linux
No comments:
Post a Comment