Skip to content

Commit

Permalink
Improvements to upstart job definition file
Browse files Browse the repository at this point in the history
- Don't start at startup, since network interfaces may not be ready.
  Instead start when the first non-loopback network interface is up.
- Use Upstart's setgid / setuid directives to run as _statsd user.
- Omit implicit 'stop on shutdown'.
- Add a conventional & friendly comment header.
- Respawn StatsD on abnormal termination, but give up after 10 tries.
- Do not redirect StatsD's output to /var/log/statsd/statsd.log. Instead
  simply allow Upstart to capture output and save it to
  /var/log/upstart/statsd.log.
  • Loading branch information
atdt committed Sep 7, 2013
1 parent ef3bd87 commit d79c4b9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 29 deletions.
1 change: 0 additions & 1 deletion debian/dirs
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
var/log/statsd
3 changes: 0 additions & 3 deletions debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@ if [ "$1" = configure ]; then
dpkg-statoverride --update --add _statsd _statsd 0755 /var/run/statsd
fi

if ! dpkg-statoverride --list /var/log/statsd >/dev/null 2>&1; then
dpkg-statoverride --update --add _statsd _statsd 0755 /var/log/statsd
fi
fi
6 changes: 1 addition & 5 deletions debian/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ if [ "$1" = purge ]; then

update-rc.d statsd remove >/dev/null || true

rm -rf /var/log/statsd /var/run/statsd

if dpkg-statoverride --list /var/log/statsd >/dev/null 2>&1; then
dpkg-statoverride --remove /var/log/statsd
fi
rm -rf /var/run/statsd

if dpkg-statoverride --list /var/run/statsd >/dev/null 2>&1; then
dpkg-statoverride --remove /var/run/statsd
Expand Down
11 changes: 0 additions & 11 deletions debian/scripts/start

This file was deleted.

1 change: 0 additions & 1 deletion debian/statsd.install
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ lib/*.js /usr/share/statsd/lib
backends/*.js /usr/share/statsd/backends
lib/*.js /usr/share/statsd/lib
debian/localConfig.js /etc/statsd
debian/scripts/start /usr/share/statsd/scripts
24 changes: 16 additions & 8 deletions debian/statsd.upstart
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
description "statsd"
author "etsy"
# statsd - Network daemon for aggregating statistics
#
# This is a network service that receives metric data via UDP from other
# applications. It aggregates this data and flushes it to a storage backend
# (typically Graphite) at regular intervals.
#
description "Network daemon for aggregating statistics"
author "Etsy"

start on startup
stop on shutdown
start on (local-filesystems and net-device-up IFACE!=lo)

script
chdir /usr/share/statsd
setuid _statsd
setgid _statsd

exec sudo -u _statsd /usr/share/statsd/debian/scripts/start
end script
respawn
respawn limit 10 5

chdir /usr/share/statsd
exec /usr/bin/nodejs stats.js /etc/statsd/localConfig.js

0 comments on commit d79c4b9

Please sign in to comment.