Skip to content

Instantly share code, notes, and snippets.

@sagarpanda
Created April 18, 2014 09:28
Show Gist options
  • Select an option

  • Save sagarpanda/11033991 to your computer and use it in GitHub Desktop.

Select an option

Save sagarpanda/11033991 to your computer and use it in GitHub Desktop.
run nodejs using upstart in ubuntu
add nodeplay.conf file in /etc/init/ directory.
It runs on server startup.
# Manually
# to start service
$ sudo start nodeplay
# to stop service
$ sudo stop nodeplay
# to check status
$ sudo status nodeplay
ref:
http://kvz.io/blog/2009/12/15/run-nodejs-as-a-service-on-ubuntu-karmic/
http://howtonode.org/deploying-node-upstart-monit
description "nodejs server"
author "sagar - http://sagarpanda.com"
# 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
# Not sure why $HOME is needed, but we found that it is:
export HOME="/root"
exec /usr/bin/node /home/path/server.js
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
@samarpanda

Copy link
Copy Markdown

Above script uses upstart. Adding the link to refer upstart usage http://upstart.ubuntu.com/cookbook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment