mysociety / planningalerts-app

Find out and have your say about what's being built and knocked down in your area.
www.planningalerts.org.au
Other
0 stars 1 forks source link

Add the search daemon to the site config in vhosts.pl and make sure it's monitored #181

Closed stevenday closed 9 years ago

lizconlan commented 9 years ago

The post-deploy script has been updated to run the rake task to restart the Sphinx daemon which will start it up if it isn't running for some reason

lizconlan commented 9 years ago

It's proving trickier to get this right than I'd thought when I first started looking at it. In a nutshell, we should be using puppet to ensure that our searchd process is present and running but there's a catch...

Although the Sphinx search engine is capable of being configured so that there's only one running searchd instance that contains configurations for multiple sites (disclaimer: setting it up is clumsy compared to, say, Apache, but the internets insist that it can be done), the Thinking Sphinx gem really isn't.

Not only does Thinking Sphinx generate its own per-project-environment configuration files but it keeps track of which model each index belongs to via the index name so an index on the Application model becomes index application which would be the same across multiple instances of the site. Without getting involved in heavily rewriting the Thinking Sphinx gem (this may be a good time to note that we're using a really old version - presumably for Rails 3.x compatibility) I can't see how that's going to work if we try to build a single Sphinx configuration file to host multiple planningalerts sites against.

Also we would intermittently lose the search on one site during deploys on another, although we could probably limit that by only restarting searchd if the config had actually changed. (At least I think that would work - without being able to sort out the index naming issue, it didn't seem worth spending too much time checking on timings for process restarts.)

If we want to keep Sphinx as our search engine, our alternative is to spawn a searchd for each deployed site, each with its own unique port number - which we'll have to generate, keep track of and put into a config somewhere :cry: A maintenance nightmare waiting to happen.

I will, of course, be delighted to stand corrected if I've missed something glaringly obvious.

lizconlan commented 9 years ago

Huh, I take that back on the basis of this 2010 thread comment from the gem author on http://freelancing-gods.com/posts/a_concise_guide_to_using_thinking_sphinx

In the most recent versions of Thinking Sphinx, you can name your indexes to whatever you want: define_index('custom') do ...