Skip to content

Instantly share code, notes, and snippets.

@garlandkr
Created August 29, 2012 16:39
Show Gist options
  • Save garlandkr/3515385 to your computer and use it in GitHub Desktop.
Save garlandkr/3515385 to your computer and use it in GitHub Desktop.
statsd init.d script with forever nodejs support
#!/bin/sh
### BEGIN INIT INFO
# Provides: statsd
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the statsd node server
# Description: starts statsd using nodejs forever
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NODE_HOME="/opt/nodejs/bin"
PATH=$PATH:$NODE_HOME
NAME=statsd
DESC=statsd
case "$1" in
start)
echo -n "Starting $DESC: "
/opt/nodejs/node_modules/forever/bin/forever \
start \
-al /var/log/node_stats_forever.log \
-ao /var/log/node_stats_out.log \
-ae /var/log/node_stats_err.log \
/opt/statsd/stats.js /etc/statsd.conf
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
/opt/nodejs/node_modules/forever/bin/forever \
stop \
/opt/statsd/stats.js
echo "$NAME."
;;
*)
echo "Usage: $NAME {start|stop}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment