Created
April 26, 2016 08:54
-
-
Save kushalhalder/0ae0f5c62ec0c0996680eb49f8ad352d 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 | |
# | |
# StatsD | |
# | |
# chkconfig: 3 50 50 | |
# description: StatsD init.d | |
. /etc/rc.d/init.d/functions | |
prog=statsd | |
STATSDDIR=/opt/statsd | |
statsd=./stats.js | |
LOG=/var/log/statsd.log | |
ERRLOG=/var/log/statsderr.log | |
CONFFILE=${STATSDDIR}/config.js | |
pidfile=/var/run/statsd.pid | |
lockfile=/var/lock/subsys/statsd | |
RETVAL=0 | |
STOP_TIMEOUT=${STOP_TIMEOUT-10} | |
start() { | |
echo -n $"Starting $prog: " | |
cd ${STATSDDIR} | |
# See if it's already running. Look *only* at the pid file. | |
if [ -f ${pidfile} ]; then | |
failure "PID file exists for statsd" | |
RETVAL=1 | |
else | |
# Run as process | |
node ${statsd} ${CONFFILE} >> ${LOG} 2>> ${ERRLOG} & | |
RETVAL=$? | |
# Store PID | |
echo $! > ${pidfile} | |
# Success | |
[ $RETVAL = 0 ] && success "statsd started" | |
fi | |
echo | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping $prog: " | |
killproc -p ${pidfile} | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] && rm -f ${pidfile} | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status -p ${pidfile} ${prog} | |
RETVAL=$? | |
;; | |
restart) | |
stop | |
start | |
;; | |
condrestart) | |
if [ -f ${pidfile} ] ; then | |
stop | |
start | |
fi | |
;; | |
*) | |
echo $"Usage: $prog {start|stop|restart|condrestart|status}" | |
exit 1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment