Skip to content

Instantly share code, notes, and snippets.

@hamidreza-s
Last active December 19, 2015 12:29
Show Gist options
  • Save hamidreza-s/5954949 to your computer and use it in GitHub Desktop.
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.
#!/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