Start nodejs app on server boot
I have one simple nodejs application which I want to start automatic when my VPS finish boot.
My server run Ubuntu's latest distribution which have a very decent version of upstart. Writing your own upstart scripts is very easy task, just copy and modify code bellow in
/etc/init/yourprogram.conf
description "NodeJs Server" author "yuks" start on started mountall stop on shutdown respawn respawn limit 99 5 script export HOME="/root" exec nodejs /projects/nodejs/public/app.js >> /var/log/node.log 2>&1 end script
Main part of this .conf file is at
exec nodejs /projects/nodejs/public/app.js >> /var/log/node.log 2>&1just modify the
/projects/nodejs/public/app.jswith your nodejs app.
Re/Start of this daemon is ridiculusly easy:
start yourprogram stop yourprogram restart yourprogramand of course this will start automaticly on boot time. Also we can view the status of daemon with this simple command:
user@nodejs:~# initctl status node-app node-app start/running, process 339
More information about NodeJs can be found at http://nodejs.org/#about