Last active
December 25, 2015 19:59
-
-
Save frahugo/7031992 to your computer and use it in GitHub Desktop.
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 :deploy do | |
# Restart passenger on deploy | |
desc "Restarting mod_rails with restart.txt" | |
task :restart, :roles => :app, :except => { :no_release => true } do | |
run "touch #{current_path}/tmp/restart.txt" | |
solr.server.restart | |
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
# lib/recipes/solr.rb | |
require 'yaml' | |
namespace :solr do | |
namespace :index do | |
desc <<-DESC | |
An after_update_code task to symlink release/index to shared/index \ | |
useful for maintaining a constant SOLR index between deployments | |
DESC | |
task :symlink, :role => :app do | |
solr.index.create | |
run <<-CMD | |
rm -rf #{release_path}/index && | |
ln -nfs #{shared_path}/index #{release_path}/index | |
CMD | |
end | |
desc "Creates the shared/index directory for persistent SOLR indexes" | |
task :create, :role => :app do | |
run "if [ ! -d #{shared_path}/index ]; then mkdir -p #{shared_path}/index ; fi" | |
end | |
desc "Removes the contents of the shared/index directory" | |
task :purge, :role => :app do | |
run "if [ -d #{shared_path}/index ]; then rm -rf #{shared_path}/index/* ; fi" | |
end | |
end | |
namespace :server do | |
desc "Start SOLR server" | |
task :start, :role => :app do | |
run "cd #{current_path} && nohup rake solr:start RAILS_ENV=#{rails_env} > log/solr.log 2> log/solr.err.log" | |
end | |
desc "Stop ferret server" | |
task :stop, :role => :app do | |
run "cd #{current_path} && RAILS_ENV=#{rails_env} rake solr:stop" | |
end | |
desc "Reindex" | |
task :reindex, :role => :app do | |
run "cd #{current_path} && RAILS_ENV=#{rails_env} rake solr:reindex" | |
end | |
desc "Restart SOLR server" | |
task :restart, :role => :app do | |
solr.server.stop | |
puts "Waiting a few seconds before starting SOLR..." | |
sleep(7) | |
solr.server.start | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment