capistrano: add deploy:rolling task (fix #4123).

This commit is contained in:
evazion
2019-08-07 22:11:07 -05:00
parent 223e5f1e81
commit c225d54de1
4 changed files with 35 additions and 7 deletions

View File

@@ -12,3 +12,6 @@ set :conditionally_migrate, true
# run migrations on the primary app server
set :migration_role, :app
# how long unicorn:legacy_restart (used by deploy:rolling) waits until killing the old unicorn.
set :unicorn_restart_sleep_time, 10

View File

@@ -0,0 +1,32 @@
namespace :app do
set :rolling_deploy, false
before "deploy:migrate", "app:disable"
after "deploy:published", "app:enable"
task :disable do
if fetch(:rolling_deploy)
# do nothing
else
invoke "web:disable"
invoke "unicorn:terminate"
end
end
task :enable do
if fetch(:rolling_deploy)
invoke "unicorn:legacy_restart"
else
invoke "unicorn:start"
invoke "web:enable"
end
end
end
namespace :deploy do
desc "Deploy a rolling update without taking the site down for maintenance"
task :rolling do
set :rolling_deploy, true
invoke "deploy"
end
end

View File

@@ -14,7 +14,3 @@ namespace :unicorn do
end
end
end
after "deploy:published", "unicorn:terminate"
after "deploy:published", "unicorn:kill"
after "deploy:published", "unicorn:start"

View File

@@ -19,6 +19,3 @@ namespace :web do
end
end
end
before "deploy:started", "web:disable"
after "deploy:published", "web:enable"