Created
July 24, 2008 09:08
-
-
Save mudge/2093 to your computer and use it in GitHub Desktop.
Using acts_as_solr with Monit and Capistrano
This file contains hidden or 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
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 |
This file contains hidden or 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
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 |
This file contains hidden or 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
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 |
This file contains hidden or 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
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