diff --git a/README.md b/README.md index 944bad7..c14f79e 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,30 @@ -# Shepherd for The @ Company swarms +# Shepherd for the Atsign swarms ## Instructions Edit -`shepherd.yaml` +``` +shepherd.yaml +``` Run -`docker stack deploy --compose-file shepherd.yaml shepherd` +``` +docker stack deploy --compose-file shepherd.yaml shepherd +``` Check the logs -`docker service logs -f shepherd_shepherd` +``` +docker service logs -f shepherd_shepherd +``` Sit back a relax and let shepherd update your secondaries... ## -# Shepherd +# Shepherd (original README) [![Build Status](https://ci.strahlungsfrei.de/api/badges/djmaze/shepherd/status.svg)](https://ci.strahlungsfrei.de/djmaze/shepherd) [![Docker Stars](https://img.shields.io/docker/stars/mazzolino/shepherd.svg)](https://hub.docker.com/r/mazzolino/shepherd/) [![Docker Pulls](https://img.shields.io/docker/pulls/mazzolino/shepherd.svg)](https://hub.docker.com/r/mazzolino/shepherd/) @@ -27,13 +33,16 @@ A Docker swarm service for automatically updating your services whenever their b ## Usage +```bash docker service create --name shepherd \ --constraint "node.role==manager" \ --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock,ro \ mazzolino/shepherd +``` ## Or with docker-compose +```yaml version: "3" services: ... @@ -46,6 +55,7 @@ A Docker swarm service for automatically updating your services whenever their b placement: constraints: - node.role == manager +``` ### Configuration diff --git a/shepherd b/shepherd index c1d7bb7..76f7167 100755 --- a/shepherd +++ b/shepherd @@ -25,6 +25,7 @@ update_services() { local registry_password="$8" local registry_host="$9" local dont_wait="${10}" + local sleep_time="${11}" local detach_option="" local registry_auth="" local insecure_registry_flag="" @@ -74,6 +75,8 @@ update_services() { currentImage=$(docker service inspect "$name" -f '{{.Spec.TaskTemplate.ContainerSpec.Image}}') if [ "$previousImage" == "$currentImage" ]; then logger "No updates to service $name!" "true" + logger "Sleeping $sleep_time before next service" "true" + sleep "$sleep_time" else logger "Service $name was updated!" if [[ "$apprise_sidecar_url" != "" ]]; then @@ -162,11 +165,11 @@ main() { [[ "$ignorelist" != "" ]] && logger "Excluding services: $ignorelist" if [[ ${RUN_ONCE_AND_EXIT+x} ]]; then - update_services "$ignorelist" "$supports_detach_option" "$supports_registry_auth" "$supports_insecure_registry" "$supports_no_resolve_image" "$image_autoclean_limit" "$registry_user" "$registry_password" "$registry_host" "$dont_wait" + update_services "$ignorelist" "$supports_detach_option" "$supports_registry_auth" "$supports_insecure_registry" "$supports_no_resolve_image" "$image_autoclean_limit" "$registry_user" "$registry_password" "$registry_host" "$dont_wait" "$sleep_time" else while true; do - update_services "$ignorelist" "$supports_detach_option" "$supports_registry_auth" "$supports_insecure_registry" "$supports_no_resolve_image" "$image_autoclean_limit" "$registry_user" "$registry_password" "$registry_host" "$dont_wait" - logger "Sleeping $sleep_time before next update" "true" + update_services "$ignorelist" "$supports_detach_option" "$supports_registry_auth" "$supports_insecure_registry" "$supports_no_resolve_image" "$image_autoclean_limit" "$registry_user" "$registry_password" "$registry_host" "$dont_wait" "$sleep_time" + logger "Sleeping $sleep_time before next run" "true" sleep "$sleep_time" done fi