Created
March 10, 2010 16:15
-
-
Save bkeepers/328018 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
after 'deploy:update_code', 'solr:symlink' | |
after 'deploy:restart', 'solr:restart' | |
namespace :solr do | |
task :symlink do | |
run "ln -nfs #{shared_path}/solr #{release_path}/solr" | |
end | |
task :reindex, :roles => :app do | |
run "cd #{current_path} && rake sunspot:solr:reindex RAILS_ENV=#{rails_env}" | |
end | |
task :start, :roles => :app do | |
run "cd #{current_path} && rake sunspot:solr:start RAILS_ENV=#{rails_env}" | |
end | |
task :stop, :roles => :app do | |
run "cd #{current_path} && rake sunspot:solr:stop RAILS_ENV=#{rails_env}" | |
end | |
task :restart, :roles => :app do | |
stop | |
start | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$original_sunspot_session = Sunspot.session | |
Before("~@search") do | |
FakeWeb.allow_net_connect = false | |
Sunspot.session = Sunspot::Rails::StubSessionProxy.new($original_sunspot_session) | |
end | |
Before("@search") do | |
unless $sunspot | |
$sunspot = Sunspot::Rails::Server.new | |
pid = fork do | |
STDERR.reopen('/dev/null') | |
STDOUT.reopen('/dev/null') | |
$sunspot.run | |
end | |
# shut down the Solr server | |
at_exit { Process.kill('TERM', pid) } | |
# wait for solr to start | |
sleep 5 | |
end | |
FakeWeb.allow_net_connect = true | |
Sunspot.session = $original_sunspot_session | |
Provider.remove_all_from_index! | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.before do | |
Sunspot.session = Sunspot::Rails::StubSessionProxy.new(Sunspot.session) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment