[refs #510] Add resque start to bluepill
This commit is contained in:
parent
bcc48d9683
commit
8dbdcee5e6
|
@ -37,7 +37,7 @@ require './lib/recipes/nginx'
|
|||
require './lib/recipes/unicorn'
|
||||
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
|
||||
|
@ -83,7 +83,7 @@ end
|
|||
after "deploy:finalize_update", "deploy:symlink_all"
|
||||
after "deploy:update_code", "deploy:migrate"
|
||||
after "deploy:setup", "deploy:symlink_pids"
|
||||
# after "deploy:restart", "bluepill:start" # "bluepill:processes:restart_dj" # "bluepill:restart"
|
||||
after "deploy:restart", "bluepill:start" # "bluepill:processes:restart_dj" # "bluepill:restart"
|
||||
|
||||
# DJ
|
||||
after "deploy:stop", "delayed_job:stop"
|
||||
|
@ -91,9 +91,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"
|
||||
|
||||
|
|
|
@ -1,46 +1,61 @@
|
|||
#! /usr/bin/env ruby
|
||||
|
||||
app_name = ENV['APP_NAME'] || 'rosa_build'
|
||||
Bluepill.application(app_name) do |app|
|
||||
Bluepill.application(app_name, :log_file => "/srv/rosa_build/shared/log/bluepill.log") do |app|
|
||||
app.uid = app.gid = 'rosa'
|
||||
app.working_dir = "/srv/#{app_name}/current"
|
||||
%w(hook default).each do |queue|
|
||||
app.process("delayed_job_#{queue}_queue") do |process|
|
||||
process.start_grace_time = 10.seconds
|
||||
process.stop_grace_time = 10.seconds
|
||||
process.restart_grace_time = 10.seconds
|
||||
#%w(hook default).each do |queue|
|
||||
# app.process("delayed_job_#{queue}_queue") do |process|
|
||||
# process.start_grace_time = 10.seconds
|
||||
# process.stop_grace_time = 10.seconds
|
||||
# process.restart_grace_time = 10.seconds
|
||||
|
||||
process.start_command = "/usr/bin/env ruby script/delayed_job --queue=#{queue} -p #{queue} --pid-dir=/srv/#{app_name}/current/tmp/#{queue}_pids start"
|
||||
process.stop_command = "/usr/bin/env ruby script/delayed_job --pid-dir=/srv/#{app_name}/current/tmp/#{queue}_pids stop"
|
||||
process.pid_file = File.join(app.working_dir, 'tmp', "#{queue}_pids", 'delayed_job.pid')
|
||||
end
|
||||
end
|
||||
# process.start_command = "/usr/bin/env ruby script/delayed_job --queue=#{queue} -p #{queue} --pid-dir=/srv/#{app_name}/current/tmp/#{queue}_pids start"
|
||||
# process.stop_command = "/usr/bin/env ruby script/delayed_job --pid-dir=/srv/#{app_name}/current/tmp/#{queue}_pids stop"
|
||||
# process.pid_file = File.join(app.working_dir, 'tmp', "#{queue}_pids", 'delayed_job.pid')
|
||||
# end
|
||||
#end
|
||||
|
||||
app.process("newrelic") do |process|
|
||||
process.start_grace_time = 10.seconds
|
||||
process.stop_grace_time = 10.seconds
|
||||
process.restart_grace_time = 10.seconds
|
||||
|
||||
path = File.join(app.working_dir, 'tmp', 'pids', 'newrelic.pid')
|
||||
process.start_command = "/usr/bin/env /usr/local/bin/nrsysmond -c /etc/newrelic/nrsysmond.cfg -p #{path}"
|
||||
process.pid_file = path
|
||||
end
|
||||
|
||||
app.process("unicorn") do |process|
|
||||
process.start_grace_time = 8.seconds
|
||||
process.stop_grace_time = 5.seconds
|
||||
process.restart_grace_time = 13.seconds
|
||||
|
||||
process.start_command = "bundle exec unicorn -l /tmp/#{app_name}_unicorn.sock -E production -c config/unicorn.rb -D"
|
||||
app.process("resque") do |process|
|
||||
process.group = "resque"
|
||||
pid_path = File.join(app.working_dir, 'tmp', 'pids', 'resque.pid')
|
||||
process.start_command = "bundle exec rake resque:work QUEUE=* PIDFILE=#{ pid_path } BACKGROUND=yes"
|
||||
process.pid_file = pid_path
|
||||
process.stop_command = "kill -QUIT {{PID}}"
|
||||
process.restart_command = "kill -USR2 {{PID}}"
|
||||
process.pid_file = File.join(app.working_dir, 'tmp', 'pids', 'unicorn.pid')
|
||||
process.daemonize = true
|
||||
|
||||
process.monitor_children do |child_process|
|
||||
child_process.stop_command = "kill -QUIT {{PID}}"
|
||||
|
||||
child_process.checks :mem_usage, :every => 10.seconds, :below => 150.megabytes, :times => [3,4], :fires => :stop
|
||||
child_process.checks :cpu_usage, :every => 10.seconds, :below => 20, :times => [3,4], :fires => :stop
|
||||
process.monitor_children do |c|
|
||||
c.stop_command = "kill -USR1 {{PID}}" # TODO: Are we really need this?
|
||||
c.checks :mem_usage, :every => 30.seconds, :below => 80.megabytes, :fires => :stop
|
||||
c.checks :running_time, :every => 30.seconds, :below => 10.minutes, :fires => :stop
|
||||
end
|
||||
end
|
||||
|
||||
#app.process("newrelic") do |process|
|
||||
# process.start_grace_time = 10.seconds
|
||||
# process.stop_grace_time = 10.seconds
|
||||
# process.restart_grace_time = 10.seconds
|
||||
|
||||
# path = File.join(app.working_dir, 'tmp', 'pids', 'newrelic.pid')
|
||||
# process.start_command = "/usr/bin/env /usr/local/bin/nrsysmond -c /etc/newrelic/nrsysmond.cfg -p #{path}"
|
||||
# process.pid_file = path
|
||||
#end
|
||||
|
||||
#app.process("unicorn") do |process|
|
||||
# process.start_grace_time = 8.seconds
|
||||
# process.stop_grace_time = 5.seconds
|
||||
# process.restart_grace_time = 13.seconds
|
||||
|
||||
# process.start_command = "bundle exec unicorn -l /tmp/#{app_name}_unicorn.sock -E production -c config/unicorn.rb -D"
|
||||
# process.stop_command = "kill -QUIT {{PID}}"
|
||||
# process.restart_command = "kill -USR2 {{PID}}"
|
||||
# process.pid_file = File.join(app.working_dir, 'tmp', 'pids', 'unicorn.pid')
|
||||
|
||||
# process.monitor_children do |child_process|
|
||||
# child_process.stop_command = "kill -QUIT {{PID}}"
|
||||
|
||||
# child_process.checks :mem_usage, :every => 10.seconds, :below => 150.megabytes, :times => [3,4], :fires => :stop
|
||||
# child_process.checks :cpu_usage, :every => 10.seconds, :below => 20, :times => [3,4], :fires => :stop
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
|
|
@ -24,12 +24,12 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|||
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} status"
|
||||
end
|
||||
|
||||
desc "Restart DJ processes"
|
||||
task :restart_dj, :roles => [:app] do
|
||||
%w(fork import hook default).each do |queue|
|
||||
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart delayed_job_#{queue}_queue"
|
||||
end
|
||||
end
|
||||
#desc "Restart DJ processes"
|
||||
#task :restart_dj, :roles => [:app] do
|
||||
# %w(fork import hook default).each do |queue|
|
||||
# run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart delayed_job_#{queue}_queue"
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
||||
desc "Start a bluepill process and load a config"
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
# -*- 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=* bundle exec rake resque:work"
|
||||
end
|
||||
end
|
||||
end
|
||||
## -*- 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
|
||||
|
|
Loading…
Reference in New Issue