Sinatra help

Yuki's Avatar

Yuki

19 Jul, 2011 02:42 PM

Hi,

I would like some help getting FS to run with my Sinatra app on Heroku. I'm very confused. So far I bundle-installed the TS and FS gems, included 'require 'flying_sphinx/tasks'' in my Rakefile, pushed to Heroku and tried to run 'heroku rake fs:index' which gives me:

Don't know how to build task 'environment'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1720:in []' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:603:inblock in invoke_prerequisites' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:602:in each' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:602:ininvoke_prerequisites' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:594:in block in invoke_with_call_chain' /usr/ruby1.9.2/lib/ruby/1.9.1/monitor.rb:201:inmon_synchronize' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:588:in invoke_with_call_chain' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:581:ininvoke' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2041:in invoke_task' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2019:inblock (2 levels) in top_level' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2019:in each' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2019:inblock in top_level' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in standard_exception_handling' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2013:intop_level' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1992:in `run'

It looks like I'm missing a config step.

Also, the pricing for Wooden on Heroku shows 20mb of indexed data, but heroku config -s shows my same shared database URL. Is the index size limit independent of how big your shared or dedicated database is?

Thanks,

Yuki

  1. Support Staff 1 Posted by Pat Allan on 19 Jul, 2011 03:13 PM

    Pat Allan's Avatar

    Hi Yuki

    This isn't really documented (I need to work on that), but in your Gemfile, you'll want to add :require options to both thinking-sphinx and flying-sphinx:

    gem 'thinking-sphinx', :require => 'thinking_sphinx/sinatra'
    gem 'flying-sphinx', :require => 'flying_sphinx/sinatra'
    

    Give that a spin, let me know how it goes (although I probably won't reply for 10 hours - it's 1:00AM here).

  2. 2 Posted by Yuki on 20 Jul, 2011 02:52 AM

    Yuki's Avatar

    Thanks Pat.

    I tried the above but still gives me the same error.

    My Gemfile:

    source 'http://rubygems.org'
    gem 'sinatra'
    gem 'redis'
    gem 'ohm'
    gem 'ohm-contrib'
    gem 'shield'
    gem 'i18n'
    gem 'yajl-ruby'
    gem 'thinking-sphinx', :require => 'thinking_sphinx/sinatra'
    gem 'flying-sphinx', :require => 'flying_sphinx/sinatra'

    Rakefile:

    require 'flying_sphinx/tasks'

  3. Support Staff 3 Posted by Pat Allan on 20 Jul, 2011 02:57 AM

    Pat Allan's Avatar

    Ah, I should have looked at my Rakefile in my test app...

    Add the following to your Rakefile - this makes sure Sinatra's paying attention to the environment and that Thinking Sphinx has the context of that environment:

    task :environment do
      Sinatra::Application.environment = ENV['RACK_ENV']
    end
    
  4. 4 Posted by Yuki on 20 Jul, 2011 03:18 AM

    Yuki's Avatar

    The above got rid of the environment error, and I was able to run the rake fs:index command, which seems to stall forever. Is this because I need a spare worker Dyno?

    Also, I had to add a bunch of dependencies in my Rakefile because I was getting uninitialized constants (Sinatra, Flying-Sphinx, Riddle). is this normal?

    require 'rubygems'
    require 'sinatra'
    require 'riddle'
    require 'thinking-sphinx'
    require 'flying-sphinx'
    require 'flying_sphinx/tasks'

    task :environment do
    Sinatra::Application.environment = ENV['RACK_ENV'] end

  5. Support Staff 5 Posted by Pat Allan on 20 Jul, 2011 03:21 AM

    Pat Allan's Avatar

    You'll want to load your bundle environment in your Rakefile - here's an example:

    require 'rubygems'
    require 'bundler'
    
    Bundler.require :default, :test
    

    This will make sure all the required constants will be defined. It may also fix up the stalling issue too (as it'll make sure you've got the Flying Sphinx settings set).

  6. 6 Posted by Yuki on 20 Jul, 2011 03:40 AM

    Yuki's Avatar

    That did it, thank you.

    I have some ActiveRecord setup to do, but I'll let you know if I have any other FS problems.

  7. Support Staff 7 Posted by Pat Allan on 20 Jul, 2011 03:43 AM

    Pat Allan's Avatar

    Great :)

  8. Pat Allan closed this discussion on 20 Jul, 2011 03:43 AM.

  9. Pat Allan re-opened this discussion on 20 Jul, 2011 10:24 AM

  10. Support Staff 8 Posted by Pat Allan on 20 Jul, 2011 10:24 AM

    Pat Allan's Avatar

    Oh, I forgot to answer the second question from this ticket - the Sphinx indices are separate from your Heroku database.

    In your Flying Sphinx dashboard (accessible through the add-ons menu of your app page within Heroku's interface) you can see how much disk space your indices are taking up. Most sites on Flying Sphinx are under the 20MB limit of the Wooden plan, but the more data that gets indexed, the larger the indices will get.

  11. Pat Allan closed this discussion on 20 Jul, 2011 10:24 AM.

  12. Yuki re-opened this discussion on 20 Jul, 2011 10:36 AM

  13. 9 Posted by Yuki on 20 Jul, 2011 10:36 AM

    Yuki's Avatar

    Oh, thanks. So FS is self contained. Is there a page on the site where I can find information about the database/version you use? I would like to use the same version for my local install.

  14. Support Staff 10 Posted by Pat Allan on 20 Jul, 2011 10:39 AM

    Pat Allan's Avatar

    The database is managed by Heroku - they use PostgreSQL, but I'm not sure which version.

    As mentioned in the docs, Flying Sphinx uses Sphinx 1.10-beta, with a custom patch for extra security (but that patch isn't really relevant on a local machine - so just Sphinx 1.10-beta or even 2.0.x-beta will be fine).

  15. Pat Allan closed this discussion on 23 Aug, 2011 11:21 PM.

Comments are currently closed for this discussion. You can start a new one.

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