node.js - How NodeJS server running for ever -


i use putty. when start server "node x.js", putty start server running. if exit putty server stop. how can keep running , make default running after restart or reboot server (computer)?

i have centos 5.10. thank you!

i use pm2 it

to install pm2

sudo npm install -g pm2 

to generate startup script

pm2 startup ubuntu(centos in case) 

then pm2 prompt command run, in case,

pm2 have run command root pm2 execute following command : pm2 sudo env path=$path:/usr/bin pm2 startup ubuntu -u username 

then run

sudo env path=$path:/usr/bin pm2 startup ubuntu -u username 

then see

pm2 generating system init script in /etc/init.d/pm2-init.sh pm2 making script booting @ startup... pm2 -ubuntu- using command su -c "chmod +x /etc/init.d/pm2-init.sh && update-rc.d pm2-init.sh defaults" adding system startup /etc/init.d/pm2-init.sh ...    /etc/rc0.d/k20pm2-init.sh -> ../init.d/pm2-init.sh    /etc/rc1.d/k20pm2-init.sh -> ../init.d/pm2-init.sh    /etc/rc6.d/k20pm2-init.sh -> ../init.d/pm2-init.sh    /etc/rc2.d/s20pm2-init.sh -> ../init.d/pm2-init.sh    /etc/rc3.d/s20pm2-init.sh -> ../init.d/pm2-init.sh    /etc/rc4.d/s20pm2-init.sh -> ../init.d/pm2-init.sh    /etc/rc5.d/s20pm2-init.sh -> ../init.d/pm2-init.sh  pm2 done. 

once have started apps , want keep them on server reboot do:

 pm2 save 

you can refer startup script section in https://github.com/unitech/pm2#startup-script


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -