-
-
Save wkettler/6995080 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/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