2011/01/21

Sphinx and daemontools

I'm moving the Big Document Warehouse Soon To Be Known As Quaero to using Sphinx for full-text searching. And of course I want to run searchd from daemontools. But searchd insists on backgrounding itself. Searching around I found people using fghack (which doesn't work) and --console (which isn't what is wanted).

However, peering into the source code to see if I could prevent it from backgrounding, I found just what I wanted: the undocumented --nodetach switch. Well, it has some documentation; there is a changelog entry that calls it a debug switch, which it isn't. Shame on you Sphinx-team!

Anyway, here is my daemontools run script:
#!/bin/bash


config=/opt/sphinx/etc/sphinx.cfg
servicename=sphinx

echo $(date "+%Y/%m/%d %H:%M:%S") $$ Sphinx searchd
exec setuidgid dw \
/opt/sphinx/bin/searchd --config $config --nodetach 2>&1 \
| /usr/bin/logger -p info -t $servicename


BTW, I have RPMs of Percona-Server (aka MySQL with a bunch of good patches) with SphinxSE.

No comments: