namespace :sunspot do desc 'setup solr data dir' task :setup_solr_data_dir do on roles :app do within shared_path do execute :mkdir, "-p #{shared_path}/solr" end end end desc 'link to solr shared dirs' task :link_to_solr_shared_dirs do on roles :app do within shared_path do execute :rm, "-rf #{release_path}/solr/solr" execute :ln, "-s #{shared_path}/solr #{release_path}/solr" execute :ln, "-s #{shared_path}/pids #{release_path}/solr/pids" end end end desc 'start solr' task :start do on roles :app do within release_path do execute :rake, "sunspot:solr:start RAILS_ENV=#{fetch :stage}" end end end desc 'stop solr' task :stop do on roles :app do within release_path do execute :rake, "sunspot:solr:stop RAILS_ENV=#{fetch :stage};true" end end end desc 'reindex solr' task :reindex do on roles :app do within release_path do execute :rake, "sunspot:solr:reindex RAILS_ENV=#{fetch :stage};true" end end end desc 'restart solr' task :restart do invoke 'sunspot:stop' sleep 1 invoke 'sunspot:start' end end after 'deploy:check', 'sunspot:setup_solr_data_dir' before 'deploy:publishing', 'sunspot:link_to_solr_shared_dirs' before 'deploy:publishing', 'sunspot:reindex'