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

georgegwu's Avatar

georgegwu

30 Jan, 2012 03:49 AM

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. Support Staff 1 Posted by Pat Allan on 30 Jan, 2012 04:21 AM

    Pat Allan's Avatar

    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. 2 Posted by George Wu on 30 Jan, 2012 02:13 PM

    George Wu's Avatar

    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. Support Staff 3 Posted by Pat Allan on 31 Jan, 2012 12:13 AM

    Pat Allan's Avatar

    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. 4 Posted by George Wu on 31 Jan, 2012 07:53 PM

    George Wu's Avatar

    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. Support Staff 5 Posted by Pat Allan on 04 Feb, 2012 03:13 AM

    Pat Allan's Avatar

    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

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

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