ThinkingSphinx ts:rebuild works in dev and test, but error in production mode.

If I set Rails 3 development db connect to my local production db, ts:rebuild works fine. So it is not a problem with the database.

-- Gemfile

gem 'thinking-sphinx', '2.0.10', :require => 'thinking_sphinx'
gem 'flying-sphinx', '0.6.1'

----- sphinx.yml

development:
  morphology: stem_en
  enable_star: true
  min_prefix_len: 3
  max_matches: 10000
  port: 9312

test:
  morphology: stem_en
  enable_star: true
  min_prefix_len: 3
  max_matches: 10000
  port: 9313

production:
  morphology: stem_en
  enable_star: true
  min_prefix_len: 3
  max_matches: 10000
  port: 9314

-------------- below is the error output when ts:rebuild RAILS_ENV = production

** Invoke ts:config (first_time)
** Invoke thinking_sphinx:configure (first_time)
** Invoke thinking_sphinx:app_env (first_time)
** Execute thinking_sphinx:app_env
** Execute thinking_sphinx:configure
Generating Configuration to /home/ubuntu/projs/demoslm/config/production.sphinx.conf
rake aborted!
Riddle::Configuration::ConfigurationError
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/riddle-1.5.1/lib/riddle/configuration/searchd.rb:24:in `render'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/riddle-1.5.1/lib/riddle/configuration.rb:29:in `render'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/configuration.rb:175:in `block in build'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/configuration.rb:174:in `open'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/configuration.rb:174:in `build'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/thinking-sphinx-2.0.10/lib/thinking_sphinx/tasks.rb:80:in `block (2 levels) in <top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `load'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `<main>'
Tasks: TOP => ts:config => thinking_sphinx:configure

  1. Hi George

    I think this is because the Flying Sphinx gem tries to load in the Sphinx configuration details when not running in dev or test environments, but because you're running this locally, the configuration environment variables that Heroku provides aren't available.

    When you're running this on Heroku, you should be using fs:rebuild instead of ts:rebuild - what's prompted you to try this in production locally?

    Cheers

    Pat

  2. Pat,

    After I went past the flying sphinx error on heroku, I still had orther
    problems. So I tried to test locally to isolate the trouble spot.

    Is there a way to test flying sphinx locally with local config as close to
    production as possible?

    Thanks,

  3. Hi George

    Try commenting out the flying-sphinx gem in your Gemfile when using the production env locally. Should allow things to work normally then.

    Cheers

    Pat

  4. Hi Pat,

    It works. It is a bit kluge.

    Can fs gem detect if it is running in Heroku or not and use that as
    indicator instead of not dev or test?

    Just a thought.

    Thanks,

    George

  5. I've just pushed a commit to http://github.com/flying-sphinx/flying-sphinx that does that - I'll get a gem release out soon.

    Thanks for the suggestion :)

Reply to this discussion Internal reply only staff will see it

Markdown

Attaching KB article:

» »

Read more…

Attach files

Up to 10MB each.

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions