Skip to content

Instantly share code, notes, and snippets.

@g8d3
Created May 29, 2013 23:04
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 g8d3/5674526 to your computer and use it in GitHub Desktop.
Save g8d3/5674526 to your computer and use it in GitHub Desktop.
Capistrano solr
#namespace :deploy do
## Ask whether to reindex before restarting Passenger
#task :restart, :roles => :app, :except => {:no_release => true} do
#solr.reindex if 'y' == Capistrano::CLI.ui.ask("\n\n Should I reindex all models? (anything but y will cancel)")
#run "touch #{File.join(current_path, 'tmp', 'restart.txt')}"
#end
#desc 'create shared data and pid dirs for Solr'
#task :setup_solr_shared_dirs do
## conf dir is not shared as different versions need different configs
#%w(data pids).each do |path|
#run "mkdir -p #{shared_path}/solr/#{path}"
#end
#end
#desc 'substituses current_path/solr/data and pids with symlinks to the shared dirs'
#task :link_to_solr_shared_dirs do
#run "mkdir #{ current_path }/solr"
#%w(solr/data solr/pids).each do |solr_path|
#run "rm -fr #{current_path}/#{solr_path}" #removing might not be necessary with proper .gitignore setup
#run "ln -s #{shared_path}/#{solr_path} #{current_path}/#{solr_path}"
#end
#end
#end
## Tasks to interact with Solr and SunSpot
#namespace :solr do
#desc "start solr"
#task :start, :roles => :app, :except => { :no_release => true } do
#run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake sunspot:solr:start"
#end
#desc "stop solr"
#task :stop, :roles => :app, :except => { :no_release => true } do
## Don't know why I have to force this way
#run "cd #{current_path} && (fuser -k -n tcp 8983 )"
#end
#desc "stop solr, remove data, start solr, reindex all records"
#task :hard_reindex, :roles => :app do
#stop
#run "rm -rf #{shared_path}/solr/data/*"
#start
#reindex
#end
#desc "simple reindex" #note the yes | reindex to avoid the nil.chomp error
#task :reindex, roles: :app do
#run "cd #{current_path} && yes | RAILS_ENV=#{rails_env} bundle exec rake sunspot:solr:reindex"
#end
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment