Last active
December 19, 2015 12:29
-
-
Save hamidreza-s/5954949 to your computer and use it in GitHub Desktop.
With this snippet of code you can create a Linux Init Script to be placed in "/etc/init.d/" an set it as a daemon with "chkconfig --add this" command.
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
#!/usr/bin/env bash | |
# chkconfig: 2345 20 80 | |
# description: Description comes here.... | |
start() { | |
# code to start app comes here | |
/path/to/forever start /path/to/app.js | |
} | |
stop() { | |
# code to stop app comes here | |
/path/to/forever stop /path/to/app.js | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart}" | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment