title: restart sunspot solr when make a deploy with capistrano in rails 3.1
body: <p>I have a project rails 3.1 in production environment.</p>
  <p><strong>This is my deploy.rb now:</strong></p>
  <pre><code>$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load pathe
  require &quot;rvm/capistrano&quot;                  # Load RVM's capistrano plugin.
  require &quot;bundler/capistrano&quot;
  set :rvm_ruby_string, 'ruby-1.9.2-p318@global'  
  set :rvm_type, :user
  set :application, &quot;domain.com&quot;
  set :user, 'user'
  
  
  #set :repository,  &quot;#{user}@ip.ip.ip.ip:~/app&quot;
  set :repository, &quot;ssh://git@bitbucket.org/user/app.git&quot;
  
  set :keep_releases, 3
  set :scm, :git
  set :use_sudo, false
  set :deploy_to, &quot;~/#{application}&quot;
  #set :deploy_via, :copy
  
  set :unicorn_conf, &quot;#{deploy_to}/current/config/unicorn.rb&quot;
  set :unicorn_pid, &quot;#{deploy_to}/shared/pids/unicorn.pid&quot;
  
  set :deploy_via, :remote_cache
  ssh_options[:forward_agent] = true
  default_run_options[:pty] = true
  
  
  role :web, &quot;ip.ip.ip.ip&quot;                          # Your HTTP server, Apache/etc
  role :app, &quot;ip.ip.ip.ip&quot;                          # This may be the same as your `Web` server
  role :db,  &quot;ip.ip.ip.ip&quot;, :primary =&gt; true # This is where Rails migrations will run
  
  
  namespace :deploy do
    
      task :restart do
          run &quot;if [ -f #{unicorn_pid} ] &amp;&amp; [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -USR2      `cat #{unicorn_pid}`; else cd #{deploy_to}/current &amp;&amp; bundle exec unicorn -c #{unicorn_conf} -E #{rails_env} -D; fi&quot;
      end
      task :start do
          run &quot;bundle exec unicorn -c #{unicorn_conf} -E #{rails_env} -D&quot;
      end
      task :stop do
          run &quot;if [ -f #{unicorn_pid} ] &amp;&amp; [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -QUIT  `    cat #{unicorn_pid}`; fi&quot;
      end
    
  end
  
  
  load 'deploy/assets'
  
  after &quot;deploy:restart&quot;, &quot;deploy:cleanup&quot; 
  </code></pre>
  <p>I want make these tasks in capistrano. Now I perform these tasks manually:</p>
  <p><strong>1º I kill sunspot solr pid with:</strong></p>
  <p>a) Find the pid with <code>ps aux | grep 'solr'</code></p>
  <p>b) Kill pid with <code>kill pid_number</code></p>
  <p><strong>2º Remove index solr in production environment if exist with:</strong></p>
  <p>a) <code>rm -r solr/data/production/index</code></p>
  <p><strong>3º turn on sunspot solr with:</strong></p>
  <p>a) <code>RAILS_ENV=production rake sunspot:solr:start</code></p>
  <p><strong>4º Reindex models with:</strong></p>
  <p>a) <code>RAILS_ENV=production rake sunspot:mongo:reindex</code></p>
  <h2> My question is: </h2>
  <p><strong>How can I add these tasks to my deploy.rb?</strong></p>
  <p>Thank you!</p>