[refs #295] deploy recipes for dj
This commit is contained in:
parent
302179eff8
commit
349e173f60
|
@ -11,7 +11,6 @@ set :default_environment, {
|
|||
|
||||
require 'rvm/capistrano'
|
||||
require 'bundler/capistrano'
|
||||
require 'delayed/recipes'
|
||||
require 'airbrake/capistrano'
|
||||
|
||||
set :whenever_command, "bundle exec whenever"
|
||||
|
@ -34,11 +33,11 @@ set :keep_releases, 3
|
|||
set :scm, :git
|
||||
set :repository, "git@github.com:warpc/rosa-build.git"
|
||||
set :deploy_via, :remote_cache
|
||||
set :delayed_job_args, "-n 4"
|
||||
|
||||
require 'lib/recipes/nginx'
|
||||
require 'lib/recipes/unicorn'
|
||||
require 'lib/recipes/bluepill'
|
||||
require 'lib/recipes/delayed_job'
|
||||
|
||||
namespace :deploy do
|
||||
task :stub_xml_rpc do
|
||||
|
|
|
@ -4,14 +4,16 @@ app_name = ENV['APP_NAME'] || 'rosa_build'
|
|||
Bluepill.application(app_name) do |app|
|
||||
app.uid = app.gid = 'rosa'
|
||||
app.working_dir = "/srv/#{app_name}/current"
|
||||
app.process("delayed_job") do |process|
|
||||
process.start_grace_time = 10.seconds
|
||||
process.stop_grace_time = 10.seconds
|
||||
process.restart_grace_time = 10.seconds
|
||||
%w(fork import 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 -n 4 start"
|
||||
process.stop_command = "/usr/bin/env ruby script/delayed_job stop"
|
||||
process.pid_file = File.join(app.working_dir, 'tmp', 'pids', 'delayed_job.pid')
|
||||
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|
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class ModifyDefaultQueue < ActiveRecord::Migration
|
||||
def up
|
||||
change_column :delayed_jobs, :queue, :string, :default => 'default'
|
||||
execute "UPDATE delayed_jobs SET queue = 'default'"
|
||||
end
|
||||
|
||||
def down
|
||||
change_column :delayed_jobs, :queue, :string, :default => nil
|
||||
execute "UPDATE delayed_jobs SET queue = null"
|
||||
end
|
||||
end
|
|
@ -24,9 +24,11 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|||
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} status"
|
||||
end
|
||||
|
||||
desc "Restart DJ process"
|
||||
desc "Restart DJ processes"
|
||||
task :restart_dj, :roles => [:app] do
|
||||
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart delayed_job"
|
||||
%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
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
Capistrano::Configuration.instance(:must_exist).load do
|
||||
namespace :delayed_job do
|
||||
def dj_queues
|
||||
%w(fork import hook default)
|
||||
end
|
||||
|
||||
def rails_env
|
||||
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
|
||||
end
|
||||
|
||||
def roles
|
||||
fetch(:delayed_job_server_role, :app)
|
||||
end
|
||||
|
||||
desc "Stop the delayed_job process"
|
||||
task :stop, :roles => lambda { roles } do
|
||||
dj_queues.each do |queue|
|
||||
run "cd #{current_path};#{rails_env} script/delayed_job --pid-dir=#{current_path}/tmp/#{queue}_pids stop"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Start the delayed_job process"
|
||||
task :start, :roles => lambda { roles } do
|
||||
dj_queues.each do |queue|
|
||||
run "cd #{current_path};#{rails_env} script/delayed_job --queue=#{queue} -p #{queue} --pid-dir=#{current_path}/tmp/#{queue}_pids start"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Restart the delayed_job process"
|
||||
task :restart, :roles => lambda { roles } do
|
||||
run "cd #{current_path};#{rails_env} script/delayed_job --queue=#{queue} -p #{queue} --pid-dir=#{current_path}/tmp/#{queue}_pids restart"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue