tag:support.flying-sphinx.com,2011-01-05:/discussions/problems/22-sinatra-helpFlying Sphinx: Discussion 2011-08-23T23:21:36Ztag:support.flying-sphinx.com,2011-01-05:Comment/87136192011-07-19T14:42:57Z2011-07-19T14:42:57ZSinatra help<div><p>Hi,</p>
<p>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:</p>
<p>Don't know how to build task 'environment'<br>
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1720:in <code>[]'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:603:in</code>block in
invoke_prerequisites' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:602:in
<code>each'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:602:in</code>invoke_prerequisites'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:594:in <code>block in
invoke_with_call_chain'
/usr/ruby1.9.2/lib/ruby/1.9.1/monitor.rb:201:in</code>mon_synchronize'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:588:in
<code>invoke_with_call_chain'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:581:in</code>invoke'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2041:in <code>invoke_task'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2019:in</code>block (2
levels) in top_level' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2019:in
<code>each'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2019:in</code>block in
top_level' /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in
<code>standard_exception_handling'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2013:in</code>top_level'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1992:in `run'</p>
<p>It looks like I'm missing a config step.</p>
<p>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?</p>
<p>Thanks,</p>
<p>Yuki</p></div>Yukitag:support.flying-sphinx.com,2011-01-05:Comment/87136192011-07-19T15:13:00Z2011-07-19T15:13:00ZSinatra help<div><p>Hi Yuki</p>
<p>This isn't really documented (I need to work on that), but in
your Gemfile, you'll want to add :require options to both
<code>thinking-sphinx</code> and <code>flying-sphinx</code>:</p>
<pre>
<code>gem 'thinking-sphinx', :require => 'thinking_sphinx/sinatra'
gem 'flying-sphinx', :require => 'flying_sphinx/sinatra'</code>
</pre>
<p>Give that a spin, let me know how it goes (although I probably
won't reply for 10 hours - it's 1:00AM here).</p></div>Pat Allantag:support.flying-sphinx.com,2011-01-05:Comment/87136192011-07-20T02:52:16Z2011-07-20T02:52:17ZSinatra help<div><p>Thanks Pat.</p>
<p>I tried the above but still gives me the same error.</p>
<p>My Gemfile:</p>
<p>source '<a href=
"http://rubygems.org">http://rubygems.org</a>'<br>
gem 'sinatra'<br>
gem 'redis'<br>
gem 'ohm'<br>
gem 'ohm-contrib'<br>
gem 'shield'<br>
gem 'i18n'<br>
gem 'yajl-ruby'<br>
gem 'thinking-sphinx', :require => 'thinking_sphinx/sinatra'<br>
gem 'flying-sphinx', :require => 'flying_sphinx/sinatra'</p>
<p>Rakefile:</p>
<p>require 'flying_sphinx/tasks'</p></div>Yukitag:support.flying-sphinx.com,2011-01-05:Comment/87136192011-07-20T02:57:27Z2011-07-20T02:57:27ZSinatra help<div><p>Ah, I should have looked at my Rakefile in my test app...</p>
<p>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:</p>
<pre>
<code>task :environment do
Sinatra::Application.environment = ENV['RACK_ENV']
end</code>
</pre></div>Pat Allantag:support.flying-sphinx.com,2011-01-05:Comment/87136192011-07-20T03:18:42Z2011-07-20T03:18:43ZSinatra help<div><p>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?</p>
<p>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?</p>
<p>require 'rubygems'<br>
require 'sinatra'<br>
require 'riddle'<br>
require 'thinking-sphinx'<br>
require 'flying-sphinx'<br>
require 'flying_sphinx/tasks'</p>
<p>task :environment do<br>
Sinatra::Application.environment = ENV['RACK_ENV'] end</p></div>Yukitag:support.flying-sphinx.com,2011-01-05:Comment/87136192011-07-20T03:21:54Z2011-07-20T03:21:54ZSinatra help<div><p>You'll want to load your bundle environment in your Rakefile -
here's an example:</p>
<pre>
<code>require 'rubygems'
require 'bundler'
Bundler.require :default, :test</code>
</pre>
<p>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).</p></div>Pat Allantag:support.flying-sphinx.com,2011-01-05:Comment/87136192011-07-20T03:40:39Z2011-07-20T03:40:42ZSinatra help<div><p>That did it, thank you.</p>
<p>I have some ActiveRecord setup to do, but I'll let you know if I
have any other FS problems.</p></div>Yukitag:support.flying-sphinx.com,2011-01-05:Comment/87136192011-07-20T03:43:15Z2011-07-20T03:43:15ZSinatra help<div><p>Great :)</p></div>Pat Allantag:support.flying-sphinx.com,2011-01-05:Comment/87136192011-07-20T10:24:04Z2011-07-20T10:24:04ZSinatra help<div><p>Oh, I forgot to answer the second question from this ticket -
the Sphinx indices are separate from your Heroku database.</p>
<p>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.</p></div>Pat Allantag:support.flying-sphinx.com,2011-01-05:Comment/87136192011-07-20T10:36:37Z2011-07-20T10:36:39ZSinatra help<div><p>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.</p></div>Yukitag:support.flying-sphinx.com,2011-01-05:Comment/87136192011-07-20T10:39:27Z2011-07-20T10:39:27ZSinatra help<div><p>The database is managed by Heroku - they use PostgreSQL, but I'm
not sure which version.</p>
<p>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).</p></div>Pat Allan