Skip to content

Commit 46cb294

Browse files
author
Caleb Troughton
committed
Add rolling_deploy_on_docker_failure option
1 parent ddd07d0 commit 46cb294

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ are the same everywhere. Settings are per-project.
375375
ports are not HTTP services, this allows you to only health check the ports
376376
that are. The default is an empty array. If you have non-HTTP services that you
377377
want to check, see Custom Health Checks in the previous section.
378+
* `rolling_deploy_on_docker_failure` => What to do when Centurion encounters an error stopping or starting a container during a rolling deploy. By default, when an error is encountered the deploy will stop and immediately raise that error. If this option is set to `:continue` Centurion will continue deploying to the remaining hosts and raise at the end.
378379

379380
###Deploy a project to a fleet of Docker servers
380381

lib/tasks/deploy.rake

+14-3
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,19 @@ namespace :deploy do
134134
end
135135

136136
task :rolling_deploy do
137+
stop_start_errors = []
137138
on_each_docker_host do |server|
138139
service = defined_service
139140

140-
stop_containers(server, service, fetch(:stop_timeout, 30))
141-
142-
container = start_new_container(server, service, defined_restart_policy)
141+
begin
142+
stop_containers(server, service, fetch(:stop_timeout, 30))
143+
container = start_new_container(server, service, defined_restart_policy)
144+
rescue e
145+
on_fail = fetch(:rolling_deploy_on_docker_failure, :exit)
146+
raise e unless on_fail == :continue
147+
stop_start_errors << e.message
148+
next
149+
end
143150

144151
public_ports = service.public_ports - fetch(:rolling_deploy_skip_ports, [])
145152
public_ports.each do |port|
@@ -158,6 +165,10 @@ namespace :deploy do
158165

159166
wait_for_load_balancer_check_interval
160167
end
168+
169+
unless stop_start_errors.empty?
170+
raise stop_start_errors.join("\n")
171+
end
161172
end
162173

163174
task :repair do

0 commit comments

Comments
 (0)