cleans up delayed_jobs for capistrano

This commit is contained in:
rgarcia
2015-09-04 00:27:14 +02:00
parent 356e987145
commit ebddcfa1d0
5 changed files with 9 additions and 49 deletions

View File

@@ -9,6 +9,7 @@ require 'capistrano/bundler'
#require 'capistrano/rails/assets' #require 'capistrano/rails/assets'
require 'capistrano/rails/migrations' require 'capistrano/rails/migrations'
#require 'capistrano/passenger' #require 'capistrano/passenger'
require 'capistrano/delayed-job'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined # Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

View File

@@ -69,6 +69,7 @@ group :development, :test do
gem "capistrano-bundler", '1.1.4', require: false gem "capistrano-bundler", '1.1.4', require: false
gem "capistrano-rails", '1.1.3', require: false gem "capistrano-rails", '1.1.3', require: false
gem "capistrano-rvm", require: false gem "capistrano-rvm", require: false
gem 'capistrano3-delayed-job', '~> 1.0'
gem "bullet" gem "bullet"
gem "faker" gem "faker"
end end

View File

@@ -79,6 +79,8 @@ GEM
capistrano-rvm (0.1.2) capistrano-rvm (0.1.2)
capistrano (~> 3.0) capistrano (~> 3.0)
sshkit (~> 1.2) sshkit (~> 1.2)
capistrano3-delayed-job (1.4.0)
capistrano (>= 3.0.0)
capybara (2.5.0) capybara (2.5.0)
mime-types (>= 1.16) mime-types (>= 1.16)
nokogiri (>= 1.3.3) nokogiri (>= 1.3.3)
@@ -406,6 +408,7 @@ DEPENDENCIES
capistrano-bundler (= 1.1.4) capistrano-bundler (= 1.1.4)
capistrano-rails (= 1.1.3) capistrano-rails (= 1.1.3)
capistrano-rvm capistrano-rvm
capistrano3-delayed-job (~> 1.0)
capybara capybara
ckeditor ckeditor
coffee-rails (~> 4.1.0) coffee-rails (~> 4.1.0)

View File

@@ -27,7 +27,7 @@ set :pty, true
set :use_sudo, false set :use_sudo, false
set :linked_files, %w{config/database.yml config/secrets.yml} set :linked_files, %w{config/database.yml config/secrets.yml}
set :linked_dirs, %w{log tmp public/system public/assets tmp/pids} set :linked_dirs, %w{log tmp public/system public/assets}
set :keep_releases, 5 set :keep_releases, 5
@@ -36,8 +36,7 @@ set :local_user, ENV['USER']
# Run test before deploy # Run test before deploy
set :tests, ["spec"] set :tests, ["spec"]
set :delayed_job_server_role, :worker set :delayed_job_workers, 2
set :delayed_job_args, "-n 2"
# Config files should be copied by deploy:setup_config # Config files should be copied by deploy:setup_config
set(:config_files, %w( set(:config_files, %w(
@@ -58,8 +57,8 @@ namespace :deploy do
after 'deploy:symlink:shared', 'deploy:compile_assets_locally' after 'deploy:symlink:shared', 'deploy:compile_assets_locally'
after :finishing, 'deploy:beta_testers' after :finishing, 'deploy:beta_testers'
after :finishing, 'deploy:cleanup' after :finishing, 'deploy:cleanup'
# Restart Delayed Job
after 'deploy:publishing', 'delayed_job:restart'
# Restart unicorn # Restart unicorn
after 'deploy:publishing', 'deploy:restart' after 'deploy:publishing', 'deploy:restart'
# Restart Delayed Jobs
after 'deploy:published', 'delayed_job:restart'
end end

View File

@@ -1,44 +0,0 @@
namespace :delayed_job do
def args
fetch(:delayed_job_args, "")
end
def delayed_job_roles
fetch(:delayed_job_server_role, :app)
end
desc 'Stop the delayed_job process'
task :stop do
on roles(delayed_job_roles) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :bundle, :exec, :'bin/delayed_job', :stop
end
end
end
end
desc 'Start the delayed_job process'
task :start do
on roles(delayed_job_roles) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :bundle, :exec, :'bin/delayed_job', args, :start
end
end
end
end
desc 'Restart the delayed_job process'
task :restart do
on roles(delayed_job_roles) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :bundle, :exec, :'bin/delayed_job', args, :restart
end
end
end
end
end