[refs #510] Add multiple workers. Change kill and start logic

This commit is contained in:
konstantin.grabar 2012-06-08 16:40:50 +04:00
parent 7a3caf01bd
commit da33173700
2 changed files with 4 additions and 2 deletions

View File

@ -38,6 +38,8 @@ require './lib/recipes/unicorn'
#require './lib/recipes/bluepill'
require './lib/recipes/delayed_job'
set :workers_count, 2
require './lib/recipes/resque'
namespace :deploy do

View File

@ -20,11 +20,11 @@ Capistrano::Configuration.instance(:must_exist).load do
end
def stop_workers
run "kill -QUIT `cat #{ fetch(:current_path) }/tmp/pids/resque.pid`"
run "kill -QUIT `ps aux | grep resque | grep -v grep | awk '{ print $2 }'`"
end
def start_workers
run "cd #{fetch :current_path} && COUNT=2 QUEUE=fork_and_import #{ rails_env } BACKGROUND=yes PIDFILE=#{ fetch(:current_path) }/tmp/pids/resque.pid bundle exec rake resque:workers"
run "cd #{fetch :current_path} && COUNT=#{ workers_count } QUEUE=fork_and_import #{ rails_env } BACKGROUND=yes bundle exec rake resque:workers"
end
end
end