Created
October 4, 2012 16:50
-
-
Save ngryman/3834896 to your computer and use it in GitHub Desktop.
Post: System V with forever for your node.js application
This file contains 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
#! /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