Skip to content

Commit

Permalink
Add rolling_deploy_on_docker_failure option
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb Troughton committed Feb 24, 2017
1 parent ddd07d0 commit 46cb294
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ are the same everywhere. Settings are per-project.
ports are not HTTP services, this allows you to only health check the ports
that are. The default is an empty array. If you have non-HTTP services that you
want to check, see Custom Health Checks in the previous section.
* `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.

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

Expand Down
17 changes: 14 additions & 3 deletions lib/tasks/deploy.rake
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,19 @@ namespace :deploy do
end

task :rolling_deploy do
stop_start_errors = []
on_each_docker_host do |server|
service = defined_service

stop_containers(server, service, fetch(:stop_timeout, 30))

container = start_new_container(server, service, defined_restart_policy)
begin
stop_containers(server, service, fetch(:stop_timeout, 30))
container = start_new_container(server, service, defined_restart_policy)
rescue e
on_fail = fetch(:rolling_deploy_on_docker_failure, :exit)
raise e unless on_fail == :continue
stop_start_errors << e.message
next
end

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

wait_for_load_balancer_check_interval
end

unless stop_start_errors.empty?
raise stop_start_errors.join("\n")
end
end

task :repair do
Expand Down

0 comments on commit 46cb294

Please sign in to comment.