Skip to content

Instantly share code, notes, and snippets.

@cbliard
Forked from erickr/statsd.init.sh
Created August 28, 2012 08:13
Show Gist options
  • Save cbliard/3496087 to your computer and use it in GitHub Desktop.
Save cbliard/3496087 to your computer and use it in GitHub Desktop.
Modified statsd.init.sh file to work on Debian with LSB functions
#!/bin/sh
#
# StatsD
#
# chkconfig: 3 50 50
# description: StatsD init.d
. /lib/lsb/init-functions
desc=statsd
STATSDDIR=/opt/statsd
statsd=stats.js
user=statsd
node=/usr/bin/node
CONFFILE=${STATSDDIR}/dConfig.js
pidfile=/var/run/statsd.pid
start() {
log_daemon_msg "Starting $desc"
# for info: no stdout/stderr with start-stop-daemon
# if we cant log, we need a bootstrap script, see http://stackoverflow.com/questions/8251933/how-can-i-log-the-stdout-of-a-process-started-by-start-stop-daemon
start-stop-daemon --start --oknodo --quiet --background --make-pidfile -p ${pidfile} -d ${STATSDDIR} --chuid ${user} --exec ${node} -- ${statsd} ${CONFFILE}
log_end_msg $?
}
stop() {
log_daemon_msg "Stopping $desc"
start-stop-daemon --stop --oknodo --quiet -p ${pidfile} --exec ${node} --retry TERM/10/KILL/5
log_end_msg $?
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status_of_proc ${node} ${desc} -p ${pidfile}
;;
restart)
stop
start
;;
*)
echo $"Usage: $desc {start|stop|restart|status}"
exit 1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment