- Go to
/etc/init/
$ sudo vim yourapp.conf
- Paste script.conf
$ sudo start yourapp
Thanks to [kvz.io] (http://kvz.io/blog/2009/12/15/run-nodejs-as-a-service-on-ubuntu-karmic/) for this!
/etc/init/
$ sudo vim yourapp.conf
$ sudo start yourapp
Thanks to [kvz.io] (http://kvz.io/blog/2009/12/15/run-nodejs-as-a-service-on-ubuntu-karmic/) for this!
description "node.js server" | |
author "Foo Bar" | |
# used to be: start on startup | |
# until we found some mounts weren't ready yet while booting: | |
start on started mountall | |
stop on shutdown | |
# Automatically Respawn: | |
respawn | |
respawn limit 99 5 | |
script | |
export HOME="/root" | |
exec /usr//bin/nodejs /where/yourapp/is/app.js >> /var/log/node.log 2>&1 | |
end script | |
post-start script | |
# Optionally put a script here that will notifiy you node has (re)started | |
# /root/bin/hoptoad.sh "node.js has started!" | |
end script |