Created
April 18, 2014 09:28
-
-
Save sagarpanda/11033991 to your computer and use it in GitHub Desktop.
run nodejs using upstart in ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Above script uses upstart. Adding the link to refer upstart usage http://upstart.ubuntu.com/cookbook