# Automating memcached startup for my app

**URL:** <https://www.ruby-forum.com/t/automating-memcached-startup-for-my-app/107535>\
**Category:** Rails\
**Created:** [June 22, 2007, 7:35pm UTC](https://www.ruby-forum.com/t/automating-memcached-startup-for-my-app/107535 "2007-06-22T19:35:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [June 22, 2007, 7:35pm UTC](https://www.ruby-forum.com/t/automating-memcached-startup-for-my-app/107535/1 "2007-06-22T19:35:11Z")

</div>

All,

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?

Thanks,  
Wes
