Skip to content

Instantly share code, notes, and snippets.

@veggiemonk
Forked from fideloper/sample-app
Created November 26, 2015 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veggiemonk/5349aac18bc3287609f0 to your computer and use it in GitHub Desktop.
Save veggiemonk/5349aac18bc3287609f0 to your computer and use it in GitHub Desktop.
Sample application Upstart script, using Forever
#!/bin/bash
# Sample App Init script for running sample app daemon
#
# chkconfig: - 98 02
#
# description: Sample Application Upstart, using Forever
APPHOME=/opt/sample-app
APPSCRIPT=app.js
PATH=/usr/bin:/sbin:/bin:/usr/sbin
export PATH
# Source function library.
. /etc/rc.d/init.d/functions
start() {
echo -n $"Starting sample-app agent: "
cd "$APPHOME" && ./forever start "$APPSCRIPT"
echo
}
stop() {
echo -n $"Stopping sample-app agent: "
cd "$APPHOME" && ./forever stop "$APPSCRIPT"
echo
}
reload() {
echo -n $"Restarting sample-app agent: "
cd "$APPHOME" && ./forever start "$APPSCRIPT"
echo
}
status() {
cd "$APPHOME" && ./forever list
}
restart() {
reload
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
reload
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload"
exit 1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment