#! /bin/sh ### BEGIN INIT INFO # Provides: carbon-cache # Required-Start: $remote_fs $syslog $network # Required-Stop: $remote_fs $syslog $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Graphite Carbon backend daemon # Description: backend data caching and persistence daemon for Graphite ### END INIT INFO # Author: Jonas Genannt global PATH := '/sbin:/usr/sbin:/bin:/usr/bin' global DESC := '"Graphite backend daemon'" global NAME := 'carbon-cache' global DAEMON := "/usr/bin/$NAME" global PIDFILE := "/var/run/$NAME.pid" global DAEMON_ARGS := ""--config=/etc/carbon/carbon.conf --pidfile=$PIDFILE --logdir=/var/log/carbon/ start"" global SCRIPTNAME := "/etc/init.d/$NAME" test -x $DAEMON || exit 0 test -r /etc/default/graphite-carbon && source /etc/default/graphite-carbon source /lib/lsb/init-functions if test ! -r /etc/carbon/carbon.conf { test $VERBOSE != no && echo "Missing /etc/carbon/carbon.conf - not starting." exit 0 } if test $CARBON_CACHE_ENABLED != "true" { test $VERBOSE != no && echo "carbon-cache disabled in /etc/default/graphite-carbon" exit 0 } proc do_start { start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ $DAEMON_ARGS \ || return 2 } proc do_stop { start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME global RETVAL := "$Status" test $RETVAL = 2 && return 2 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON test "$Status" = 2 && return 2 rm -f $PIDFILE return $RETVAL } matchstr $1 { start { test $VERBOSE != no && log_daemon_msg "Starting $DESC" $NAME do_start matchstr "$Status" { 0|1 { test $VERBOSE != no && log_end_msg 0 } 2 { test $VERBOSE != no && log_end_msg 1 } } } stop { test $VERBOSE != no && log_daemon_msg "Stopping $DESC" $NAME do_stop matchstr "$Status" { 0|1 { test $VERBOSE != no && log_end_msg 0 } 2 { test $VERBOSE != no && log_end_msg 1 } } } status { status_of_proc $DAEMON $NAME && exit 0 || exit $Status } restart|force-reload { log_daemon_msg "Restarting $DESC" $NAME do_stop matchstr "$Status" { 0|1 { do_start matchstr "$Status" { 0 { log_end_msg 0 } 1 { log_end_msg 1 } * { log_end_msg 1 } } } * { log_end_msg 1 } } } * { echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" > !2 exit 3 } } :