capistrano: add deploy:rolling task (fix #4123).
This commit is contained in:
@@ -12,3 +12,6 @@ set :conditionally_migrate, true
|
|||||||
|
|
||||||
# run migrations on the primary app server
|
# run migrations on the primary app server
|
||||||
set :migration_role, :app
|
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
|
||||||
|
|||||||
32
lib/capistrano/tasks/app.rake
Normal file
32
lib/capistrano/tasks/app.rake
Normal 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
|
||||||
@@ -14,7 +14,3 @@ namespace :unicorn do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
after "deploy:published", "unicorn:terminate"
|
|
||||||
after "deploy:published", "unicorn:kill"
|
|
||||||
after "deploy:published", "unicorn:start"
|
|
||||||
|
|||||||
@@ -19,6 +19,3 @@ namespace :web do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
before "deploy:started", "web:disable"
|
|
||||||
after "deploy:published", "web:enable"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user