Skip to content

Instantly share code, notes, and snippets.

@fideloper
Created May 15, 2013 20:02
Show Gist options
  • Save fideloper/5586913 to your computer and use it in GitHub Desktop.
Save fideloper/5586913 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