hectcastro/chef-statsd — pull request #19 by gansbrest (2013-06-06 22:16:12+00:00)
Title: Use runit to start / stop statsd process. Much more reliable than previous init scripts.

I know that it's kind of big change, but it seems pretty straightforward and useful. Here is why:

We use AMS image ( amazon ami ) and I noticed that after fresh install when chef-client is running as part of bootstrap process ( not the same thing when you bootstrap with knife ) statsd process was missing.. After looking a little more, I noticed error message in the log "sudo: sorry, you must have a tty to run sudo" which makes perfect sense when you statsd init script is invoked by the main init process.

I was thinking to do a quick fix and replace sudo -u statsd -- with su statsd -c "command". I even created a branch for this, but quickly realized that it wasn't such a great idea because that would impose some additional constrains like the need to have real shell assigned for statsd use ( that's easy ) but the trickiest part was to monitor statsd process id, so it could be stopped easliy. When you use su -c , you can't easily parse out process id by using ps aux command, because there are multiple processes with this name.

And then it hit me - why reinvent the wheel and deal with process babysitting and using wired & to send process to the background if we could use excellent runit cookbook to do just that. So I sat down and rewrote it with runit support.

I hope you will consider the change.