Refactor bluepill deploy recipies. Restart DJ through bluepill. Refs #196

This commit is contained in:
Pavel Chipiga 2012-02-17 16:32:03 +02:00 committed by Vladimir Sharshov
parent c972968338
commit 432b6ac276
3 changed files with 36 additions and 17 deletions

View File

@ -62,8 +62,9 @@ namespace :deploy do
end
after "deploy:update_code", "deploy:symlink_all", "deploy:migrate"
after "deploy:restart","bluepill:stop", "delayed_job:restart", "deploy:cleanup", "bluepill:start"
after "deploy:setup", "deploy:symlink_pids"
after "deploy:restart","bluepill:processes:restart_dj" # "bluepill:restart"
after "deploy:restart", "deploy:cleanup"
require 'cape'
namespace :rake_tasks do

View File

@ -11,6 +11,7 @@ Bluepill.application(app_name) do |app|
process.start_command = "/usr/bin/env RAILS_ENV=production script/delayed_job start"
process.stop_command = "/usr/bin/env RAILS_ENV=production script/delayed_job stop"
process.restart_command = "/usr/bin/env RAILS_ENV=production script/delayed_job restart"
process.pid_file = File.join(app.working_dir, 'tmp', 'pids', 'delayed_job.pid')
end

View File

@ -3,29 +3,46 @@ Capistrano::Configuration.instance(:must_exist).load do
namespace :bluepill do
set(:bluepill_binary) {"bundle exec bluepill --no-privileged"}
desc "Load bluepill configuration and start it"
namespace :processes do
desc "Start processes that bluepill is monitoring"
task :start, :roles => [:app] do
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} start"
end
desc "Stop processes that bluepill is monitoring"
task :stop, :roles => [:app], :on_error => :continue do
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} stop"
end
desc "Restart processes that bluepill is monitoring"
task :restart, :roles => [:app] do
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart"
end
desc "Prints bluepills monitored processes statuses"
task :status, :roles => [:app] do
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} status"
end
desc "Restart DJ process"
task :restart_dj, :roles => [:app] do
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart delayed_job"
end
end
desc "Start a bluepill process and load a config"
task :start, :roles => [:app] do
run "cd #{fetch :current_path} && #{try_sudo} APP_NAME=#{fetch :application} #{bluepill_binary} load config/production.pill"
end
desc "Stop processes that bluepill is monitoring"
task :stop, :roles => [:app], :on_error => :continue do
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} stop"
end
task :restart, :roles => [:app] do
# run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart"
stop; quit; start
end
desc "Stop processes that bluepill is monitoring and quit bluepill"
task :quit, :roles => [:app] do
desc "Quit bluepill"
task :stop, :roles => [:app] do
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} quit"
end
desc "Prints bluepills monitored processes statuses"
task :status, :roles => [:app] do
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} status"
desc "Completely restart bluepill and monitored services"
task :restart, :roles => [:app] do
processes.stop; stop; start
end
end
end