Automating memcached startup for my app


My app. requires memcached, and I’d like to build any necessary
restarting of the memcached daemon into my site startup. (I already
have my script executing as part of a deploy, but I’d like to
“bulletproof” it more if possible).

I wrote a script which will restart memcached if it isn’t there.

My problem is I need to reliably invoke it whenever my production site
is started.

I’m using Apache with FCGI (and yes, I will be migrating to Mongrel
soon). I attempted to use production.rb/environment.rb to handle this,
but I couldn’t get the system calls to work, and anyway, I don’t really
want multiple Ruby processes (either FCGI or Mongrel) competing to start
the memcached daemon anyway.

So I’d really like to hook the startup script I wrote into the startup
process for Apache. Is there a natural hook for this that Apache
provides where I can issue arbitrary commands as part of starting up the
httpd daemon? Or do I need to customize the apachectl script or
something equally invasive?