Skip to content

Instantly share code, notes, and snippets.

@lunalium
Forked from doitian/solr_cap.rb
Created January 31, 2016 16:29
Show Gist options
  • Select an option

  • Save lunalium/cca5fb9d321512f39b0b to your computer and use it in GitHub Desktop.

Select an option

Save lunalium/cca5fb9d321512f39b0b to your computer and use it in GitHub Desktop.

Revisions

  1. @doitian doitian created this gist Feb 11, 2012.
    25 changes: 25 additions & 0 deletions solr_cap.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    namespace :deploy do
    task :setup_solr_data_dir do
    run "mkdir -p #{shared_path}/solr/data"
    end
    end

    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 sunspot-solr start --port=8983 --data-directory=#{shared_path}/solr/data --pid-dir=#{shared_path}/pids"
    end
    desc "stop solr"
    task :stop, :roles => :app, :except => { :no_release => true } do
    run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec sunspot-solr stop --port=8983 --data-directory=#{shared_path}/solr/data --pid-dir=#{shared_path}/pids"
    end
    desc "reindex the whole database"
    task :reindex, :roles => :app do
    stop
    run "rm -rf #{shared_path}/solr/data"
    start
    run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake sunspot:solr:reindex"
    end
    end

    after 'deploy:setup', 'deploy:setup_solr_data_dir'