-
-
Save erickr/1326359 to your computer and use it in GitHub Desktop.
Modified statsd.init.sh file to work on Debian
This file contains hidden or 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 | |
. /lib/lsb/init-functions | |
prog=statsd | |
STATSDDIR=/opt/statsd | |
statsd=stats.js | |
LOG=/var/log/statsd.log | |
ERRLOG=/var/log/statsderr.log | |
CONFFILE=${STATSDDIR}/conf.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 | |
log_failure_msg "PID file exists for statsd" | |
RETVAL=1 | |
else | |
# Run as process | |
/usr/local/bin/node ${statsd} ${CONFFILE} >> ${LOG} 2>> ${ERRLOG} & | |
RETVAL=$? | |
# Store PID | |
echo $! > ${pidfile} | |
# Success | |
[ $RETVAL = 0 ] && log_success_msg "statsd started" | |
fi | |
echo | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping $prog: " | |
killproc -p ${pidfile} | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] && rm -f ${pidfile} && log_success_msg "statsd stopped" | |
} | |
# 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
I have adapted it to rely on LSB functions, use start-stop-daemon, and run as a specific user. But I lost the logs
Here is the version