Skip to content

Instantly share code, notes, and snippets.

@wkettler
Forked from chalmerj/gist:1492384
Last active December 25, 2015 14:59
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 wkettler/6995080 to your computer and use it in GitHub Desktop.
Save wkettler/6995080 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# carbon-cache
#
# Graphite's carbon-cache daemon init script.
#
# William Kettler <william.p.kettler@gmail.com>
#
# Source init-functions
. /lib/lsb/init-functions
PATH=/bin:/sbin
# Path to Graphite
DAEMON_PATH=/opt/graphite/bin
DAEMON=$DAEMON_PATH/carbon-cache.py
# Name of executable daemon
NAME=carbon-cache
PIDFILE=/opt/graphite/storage/carbon-cache-a.pid
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
if [ ! -x "$DAEMON" ]; then
echo "$DAEMON does not exist or is not executable"
exit 1
fi
start() {
echo "* Starting $NAME"
start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON start
if [ $? -ne 0 ]; then
echo "...failed"
exit 1
else
echo "...done"
fi
}
stop() {
echo "* Stopping $NAME"
start-stop-daemon --stop --signal 2 --retry 5 --pidfile $PIDFILE
if [ $? -ne 0 ]; then
echo "...failed"
exit 1
else
echo "...done"
fi
}
status() {
echo "* Checking $NAME status..."
$DAEMON status
if [ $? -ne 0 ]; then
exit 1
fi
}
# Display / Parse Init Options
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment