God, sphinx, and you
god is my newest favorite tool for server and Rails monitoring, not to mention the entertaining conversations it can produce(”God was spanking the mongrels repeatedly, without letting them fully start”, “god spammed my mailbox with over 700 emails this weekend”, “I’m killing god right now, it should be back in a minute”). One of the last pieces I forgot to include in this setup was Sphinx and, in an apt demonstration of Murphy’s law, it decided to silently die this weekend while I was out of town. So the first thing I did today was to let god manage it as well.
One hurdle people might run into is whether to let god auto-daemonize the process(a useful feature indeed), but our hand is forced by Sphinx already daemonizing itself along with its own PID file(trying to let both god and a process daemonize itself is pretty much crossing the streams). Fortunately, sphinx provides its own “stop” command so we don’t have to go crazy trying to lookup a PID in our god config:
Easy peasy. I absolutely adore god's ability to plug into the event system on OSX, so between god and launchd, I've almost got a bulletproof config[1].
w.start = "searchd -c #{RAILS_ROOT}/config/#{RAILS_ENV}.sphinx.conf"
w.stop = "searchd -c #{RAILS_ROOT}/config/#{RAILS_ENV}.sphinx.conf --stop"
w.pid_file = File.join(RAILS_ROOT, "log/searchd.#{RAILS_ENV}.pid")
[1] “bulletproof” for the value of “resists .22 rounds hand-thrown at it by a grade-schooler”, mind you.
Loading...