Created
August 26, 2010 14:22
-
-
Save kyleburton/551475 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
. /lib/lsb/init-functions | |
PATH=/bin:/usr/bin:/sbin:/usr/sbin | |
DAEMON=/var/lib/the-clj-service/the-clj-service.sh | |
NAME=the-clj-service | |
# any args passed to the process | |
SERVICES_OPTS="${2:-}" | |
PIDDIR="/var/run/the-clj-service" | |
PIDFILE="$PIDDIR/daemon.pid" | |
USER="servicerunner" | |
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" | |
if [ ! -d $PIDDIR ]; then | |
mkdir $PIDDIR | |
chown servicerunner.servicerunner $PIDDIR | |
fi | |
case "$1" in | |
start) | |
log_daemon_msg "Starting the clojure service server" "$DAEMON" | |
start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON --chuid $USER -- $SERVICES_OPTS | |
sleep 2 | |
$0 status | |
;; | |
stop) | |
log_daemon_msg "Starting the clojure service server" "$DAEMON" | |
if start-stop-daemon --stop --quiet --pidfile $PIDFILE; then | |
log_end_msg 0 | |
exit 0 | |
else | |
log_end_msg 1 | |
exit 1 | |
fi | |
;; | |
reload) | |
log_daemon_msg "Re-Loading Starting the clojure service configuration" "$DAEMON" | |
echo "Error: not implemented - need to ticle the daemon somehow (hit a url?)" | |
exit 1 | |
;; | |
restart) | |
log_daemon_msg "Re-Starting clojure service server" "$DAEMON" | |
start-stop-daemon --signal TERM --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE | |
start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON --chuid $USER -- $SERVICES_OPTS | |
sleep 2 | |
$0 status | |
;; | |
status) | |
status_of_proc -p $PIDFILE $DAEMON the-clj-service && exit 0 || exit $? | |
;; | |
*) | |
log_action_msg "Usage: $0 {start|stop|reload|restart|status}" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment