Closed agibralter closed 12 years ago
Hi Aaron
There's two things to do for this - first, add the version of Sphinx to your sphinx.yml file:
production:
version: 2.0.1-beta
And then, in an initialiser, you'll want something like this:
ThinkingSphinx.remote_sphinx = Rails.env.production?
That should do the trick
Hi Pat,
That did indeed work. Though in the process of investigating, I found that I might also want to set the ENV["SPHINX_VERSION"] variable on servers without searchd installed: https://github.com/freelancing-god/riddle/blob/master/lib/riddle/auto_version.rb. It seems to work without it, but I'm not sure if that's a problem or not: i.e., is the sphinx-version-specific riddle stuff important for the riddle clients connecting remotely?
I thought that riddle would also read the version
from sphinx.yml, but that does not seem to be the case.
Also! This may be another issue, or just an aside, but the new shuffle
sphinx.yml config variable caused a ton of trouble for me! Basically, shuffle
is by default true
. On my sphinx server (the one running searchd), in order to both bind searchd to 0.0.0.0 (to allow both remote and local connections) instead of 127.0.0.1 (just local connections) or search.example.com (just remote connections), I have address
set to nil in my sphinx.yml file. This achieves the goal of having searchd run and bind to 0.0.0.0, but it also (previously) meant that local connections from, say, rails c
on the sphinx server would default to connecting to localhost since address is nil. Now, however, with shuffle
: https://github.com/freelancing-god/thinking-sphinx/blob/master/lib/thinking_sphinx/configuration.rb#L340 this line causes Riddle to blow up: https://github.com/freelancing-god/riddle/blob/master/lib/riddle/client.rb#L144. servers
is no longer nil
, but rather []
, and I end up Array([])
instead of Array("localhost")
. As you can imagine that was a bit confusing, but setting shuffle
to false
in sphinx.yml solved it. I just had no idea it was there... maybe something for the README?
Thanks for the detail Aaron... I think I'll change the default for shuffle to false, given it's not what most people will want or expect.
Also, ENV['SPHINX_VERSION']
was added just for testing on Travis (because it's the one test setup used for different versions, so sphinx.yml wasn't an option). Having remote clients using the right version is important, as they'll communicate with the daemon using the latest protocol. In some cases, there might be better performance.
Ah. Ok, I see. On "remote" machines without searchd installed, ENV['SPHINX_VERSION']
has to be set since sphinx.yml does not get read by Riddle, right? Would it all make sense for Riddle's version check to try for searchd -v
then sphinx.yml
then ENV
?
sphinx.yml is for Thinking Sphinx, not Riddle - and annoyingly, there's been no -v flag for searchd/indexer, so it's a matter of running the command and grepping the output.
So, SPHINX_VERSION
is for Riddle, but that shouldn't matter if you're using Thinking Sphinx, as you've got sphinx.yml instead.
Ahh, ok -- for some reason when I was tracing the logic it didn't seem like ThinkingSphinx was passing the sphinx.yml "version" parameter to Riddle when setting up the client connection on the remote machines. I could be mistaken though...
On Sun, Dec 18, 2011 at 10:16 PM, Pat Allan < reply@reply.github.com
wrote:
sphinx.yml is for Thinking Sphinx, not Riddle - and annoyingly, there's been no -v flag for searchd/indexer, so it's a matter of running the command and grepping the output.
So,
SPHINX_VERSION
is for Riddle, but that shouldn't matter if you're using Thinking Sphinx, as you've got sphinx.yml instead.
Reply to this email directly or view it on GitHub:
https://github.com/freelancing-god/thinking-sphinx/issues/314#issuecomment-3198835
Ah, you are right - TS doesn't push the manually configured version through to Riddle. Patch to fix would be welcome :)
Hmm but it doesn't seem so simple. When Riddle is required, it Autoloads the correct version of riddle's sphinx libs based on a Riddle::Controller
not touched by TS: https://github.com/freelancing-god/riddle/blob/master/lib/riddle/auto_version.rb.
Do you think Riddle::AutoVersion.configure
can be evaluated a bit more lazily?
I guess it could be, though not a fan of adding in that extra complexity. But in the end, shouldn't TS require the right version of Riddle, and so Riddle.loaded_version gets set appropriately?
Ahh ok -- sorry for the runaround!
So https://github.com/freelancing-god/thinking-sphinx/blob/master/lib/thinking_sphinx/auto_version.rb causes the correct version of Riddle to get loaded (eventually).
This line https://github.com/freelancing-god/thinking-sphinx/blob/master/lib/thinking_sphinx.rb#L4 causes Riddle::AutoVersion.configure
to run, and on systems without searchd
, controller.sphinx_version
will just be nil
at that point.
I guess I was just afraid that multiple calls to require 'riddle/x.x.x'
would occur (once during require 'riddle'
and once in thinking_sphinx/auto_version.rb
), but that does not seem to be the case.
ThinkingSphinx::AutoVersion.detect gets called in a Railtie initialiser - so it should only get called once, as the Rails app is loading. So yeah, should be fine :)
:) thank you for putting up with my shenanigans there...
No worries, good to have it all clarified in my mind too :)
"Sphinx cannot be found on your system. You may need to configure the following"
My backend servers connect to a remote machine running thinking-sphinx/searchd. Is there any way to suppress the warnings that happen when booting my backend machines?