Skip to content

Commit

Permalink
Restrict runtime of "docker service update" using "timeout" (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
fooflington authored Feb 27, 2023
1 parent 48acf00 commit a947a6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ You can set Shepherd to roll back a service to the previous version if the updat

You can control additional parameters for the `docker service update` and `docker service update --rollback` calls using the variables `UPDATE_OPTIONS` and `ROLLBACK_OPTIONS`.

If the `docker service update` takes too long then it will be killed after 5 minutes by default. You can adjust this value using the `TIMEOUT` variable.

You can enable private registry authentication by setting the `WITH_REGISTRY_AUTH` variable.

If you need to authenticate to a registry (for example in order to get around the [Docker Hub rate limits](https://www.docker.com/increase-rate-limit)), you can set the variable `REGISTRY_USER` and store the password either in a [docker secret](https://docs.docker.com/engine/swarm/secrets/) named `shepherd_registry_password` or in the environment variable `REGISTRY_PASSWORD`. If you are not using Docker Hub but a private registry, set `REGISTRY_HOST` to the hostname of your registry.
Expand Down
2 changes: 1 addition & 1 deletion shepherd
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ update_services() {
logger "Trying to update service $name with image $image" "true"

# shellcheck disable=SC2086
if ! docker "${config_flag[@]}" service update "$name" $detach_option $registry_auth $no_resolve_image_flag ${UPDATE_OPTIONS} --image="$image" > /dev/null; then
if ! timeout "${TIMEOUT:-300}" docker "${config_flag[@]}" service update "$name" $detach_option $registry_auth $no_resolve_image_flag ${UPDATE_OPTIONS} --image="$image" > /dev/null; then
logger "Service $name update failed on $hostname!"
if [[ "${ROLLBACK_ON_FAILURE+x}" ]]; then
logger "Rolling $name back"
Expand Down

0 comments on commit a947a6b

Please sign in to comment.