Skip to content

Instantly share code, notes, and snippets.

@tcopple
Created October 7, 2011 20:16
Show Gist options
  • Save tcopple/1271257 to your computer and use it in GitHub Desktop.
Save tcopple/1271257 to your computer and use it in GitHub Desktop.
an init.d script to start and top resque-web under the user 'resquer'
#! /bin/sh
### BEGIN INIT INFO
# Provides: resque-web
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: web interface for resque processing
# Description: resque-web interface for resque
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=resque-web
DESC=resque-web
DAEMON=/home/resquer/.rvm/bin/boot_resque-web
DAEMON_START_ARGS="-L -p 4001"
DAEMON_STOP_ARGS="-K"
test -x $DAEMON || exit 0
test -x $DAEMONBOOTSTRAP || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
echo "\n"$DAEMON $DAEMON_START_ARGS
if start-stop-daemon --start --umask 007 --chuid resquer:resquer --exec $DAEMON -- $DAEMON_START_ARGS
then
echo "$NAME."
else
echo "failed"
fi
;;
stop)
echo -n "Stopping $DESC: "
echo "\n"$DAEMON $DAEMON_STOP_ARGS
if start-stop-daemon --start --umask 007 --chuid resquer:resquer --exec $DAEMON -- $DAEMON_STOP_ARGS
then
echo "$NAME."
else
echo "failed"
fi
;;
restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment