Skip to content

Instantly share code, notes, and snippets.

@mudge
Created July 24, 2008 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mudge/2093 to your computer and use it in GitHub Desktop.
Save mudge/2093 to your computer and use it in GitHub Desktop.
Using acts_as_solr with Monit and Capistrano
before :deploy, "solr:stop"
after :deploy, "solr:start"
namespace :solr do
task :stop, :roles => :app do
run "#{sudo} monit stop solr"
end
task :start, :roles => :app do
run "#{sudo} monit start solr"
end
end
namespace :solr do
task :rebuild_and_optimize, :roles => :app do
run "rake -f #{current_path}/Rakefile solr:rebuild_indexes RAILS_ENV=production"
run "rake -f #{current_path}/Rakefile solr:optimize RAILS_ENV=production"
end
end
check process solr with pidfile /path/to/project/current/vendor/plugins/acts_as_solr/solr/tmp/production_pid
start program = "/usr/bin/rake -f /path/to/project/current/vendor/plugins/acts_as_solr/lib/tasks/solr.rake solr:start RAILS_ENV=production"
stop program = "/usr/bin/rake -f /path/to/project/current/vendor/plugins/acts_as_solr/lib/tasks/solr.rake solr:stop RAILS_ENV=production"
if failed host 127.0.0.1 port 8983 protocol http and request "/solr" then restart
if 3 restarts within 5 cycles then timeout
namespace :solr do
task :rebuild_indexes => :environment do
[ Model1, Model2 ].each { |a| a.rebuild_solr_index(300) }
end
task :optimize => :environment do
[ Model1, Model2 ].each { |a| a.solr_optimize }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment