Skip to content

Instantly share code, notes, and snippets.

@ngryman
Created October 4, 2012 16:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngryman/3834896 to your computer and use it in GitHub Desktop.
Save ngryman/3834896 to your computer and use it in GitHub Desktop.
Post: System V with forever for your node.js application
#! /bin/sh
### BEGIN INIT INFO
# Provides: your_application
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: your fancy description that no one will see ;)
# Description: This file should be used to construct scripts to be placed in /etc/init.d.
#
### END INIT INFO
# Only start is supported here
# To manager your_application, use forever
case "$1" in
start)
echo "Starting your_application"
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /home/user/path/to/server/syslog 2>&1
sudo -u user -i NODE_ENV=production forever start /home/user/path/to/server >> /home/user/path/to/server/syslog 2>&1
;;
*)
echo "Usage: /etc/init.d/start start"
echo " forever {stop|restart}"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment