Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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