Skip to content

Instantly share code, notes, and snippets.

@wcoder
Created January 17, 2016 17:03
Show Gist options
  • Save wcoder/bc7c5cc465f43c0b7f2c to your computer and use it in GitHub Desktop.
Save wcoder/bc7c5cc465f43c0b7f2c to your computer and use it in GitHub Desktop.
unstart config (/etc/init/) for run node.js app as the service
description "node.js server"
author "Yuaheni Pakala"
# 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"
chdir /path/to/your/node-app
exec nodejs server.js >> /var/log/my-app.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
@wcoder
Copy link
Author

wcoder commented Mar 6, 2016

using

sudo service nodeapp start/stop/restart

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