Search code examples
ruby-on-railsubuntuthinking-sphinx

start thinking sphinx on rails server startup


I have a chain of nginx + passenger for my rails app.

Now after each server restart i need to write in terminal in project folder

rake ts:start

but how can i automatize it?

So that after each server restart thinking sphinx is automatically started without my command in terminal?

I use rails 3.2.8 and ubuntu 12.04.

I can not imagine what can i try ever, please help me.

How can i do this, give some advices?


Solution

  • There's two options I can think of.

    • You could look at how Ubuntu manages start-up scripts and add one for this (perhaps in /etc/init?).
    • You could set up monit or another monitoring tool and have it keep Sphinx running. Monit should boot automatically when your server restarts, and so it should ensure Sphinx (and anything else it's tracking) is running.

    The catch with Monit and other such tools is that when you deliberately stop Sphinx (say, to update configuration structure and corresponding index changes), it might start it up again before it's appropriate. So I think you should start with the first of these two options - I just don't know a great deal about the finer points of that approach.