Skip to content

Instantly share code, notes, and snippets.

@ngryman
Created October 2, 2012 21:10
Show Gist options
  • Save ngryman/3823330 to your computer and use it in GitHub Desktop.
Save ngryman/3823330 to your computer and use it in GitHub Desktop.
Post: Using upstart with forever to manage your node.js application
#!upstart
description "your fancy description that no one will see ;)"
author "Your Name <youremail@fqdn>"
# start on every run level, 2 is the one on Ubuntu
start on runlevel [2345]
# stop on halt, maintenance or reboot
stop on runlevel [016]
# start our application with the user `user`
exec sudo -u user -i NODE_ENV=production forever start /home/user/path/to/server >> /home/user/path/to/server/syslog 2>&1
# starting log
pre-start script
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /home/user/path/to/server/syslog 2>&1
end script
@andreyvolokitin
Copy link

Why this script has .sh extension? It needs to be placed at /etc/init?

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