[refs #510] Resque deploy refactor. Turn off bluepill

This commit is contained in:
konstantin.grabar 2012-06-07 19:13:58 +04:00
parent da9d7574d1
commit 597ac65dee
3 changed files with 42 additions and 48 deletions

View File

@ -35,9 +35,10 @@ set :deploy_via, :remote_cache
require './lib/recipes/nginx'
require './lib/recipes/unicorn'
require './lib/recipes/bluepill'
#require './lib/recipes/bluepill'
require './lib/recipes/delayed_job'
#require './lib/recipes/resque'
require './lib/recipes/resque'
namespace :deploy do
task :stub_xml_rpc do
@ -85,9 +86,9 @@ after "deploy:update_code", "deploy:migrate"
after "deploy:setup", "deploy:symlink_pids"
# Bluepill
after "deploy:restart", "bluepill:restart" # "bluepill:processes:restart_dj" # "bluepill:restart"
after "deploy:start", "bluepill:start"
after "deploy:stop", "bluepill:stop"
#after "deploy:restart", "bluepill:restart" # "bluepill:processes:restart_dj" # "bluepill:restart"
#after "deploy:start", "bluepill:start"
#after "deploy:stop", "bluepill:stop"
# DJ
after "deploy:stop", "delayed_job:stop"
@ -95,9 +96,9 @@ after "deploy:start", "delayed_job:start"
after "deploy:restart", "delayed_job:restart"
# Resque
#after "deploy:stop", "resque:stop"
#after "deploy:start", "resque:start"
#after "deploy:restart", "resque:restart"
after "deploy:stop", "resque:stop"
after "deploy:start", "resque:start"
after "deploy:restart", "resque:restart"
after "deploy:restart", "deploy:cleanup"

View File

@ -23,6 +23,9 @@ Bluepill.application(app_name, :log_file => "/srv/rosa_build/shared/log/bluepill
process.pid_file = pid_path
process.stop_command = "kill -QUIT {{PID}}"
process.daemonize = true
process.start_grace_time = 5.seconds
process.stop_grace_time = 5.seconds
process.restart_grace_time = 5.seconds
#process.monitor_children do |c|
# c.stop_command = "kill -USR1 {{PID}}" # TODO: Are we really need this?

View File

@ -1,40 +1,30 @@
## -*- encoding : utf-8 -*-
#Capistrano::Configuration.instance(:must_exist).load do
#
# require 'resque/server'
#
# namespace :resque do
# task :start do
# start_workers
# end
#
# task :stop do
# stop_workers
# end
#
# task :restart do
# stop_workers
# start_workers
# end
#
# def rails_env
# fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
# end
#
# def stop_workers
# pids = Array.new
#
# Resque.workers.each do |worker|
# pids << worker.to_s.split(/:/)[1]
# end
#
# if pids.size > 0
# system("kill -QUIT #{pids.join(' ')}")
# end
# end
#
# def start_workers
# run "cd #{fetch :release_path} && QUEUE=* #{ rails_env } bundle exec rake resque:work &"
# end
# end
#end
# -*- encoding : utf-8 -*-
Capistrano::Configuration.instance(:must_exist).load do
namespace :resque do
task :start do
start_workers
end
task :stop do
stop_workers
end
task :restart do
stop_workers
start_workers
end
def rails_env
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
end
def stop_workers
run "kill -QUIT `cat #{ fetch(:current_path) }/tmp/pids/resque.pid`"
end
def start_workers
run "cd #{fetch :current_path} && QUEUE=fork_and_import #{ rails_env } BACKGROUND=yes PIDFILE=#{ fetch(:current_path) }/tmp/pids/resque.pid bundle exec rake resque:work"
end
end
end