Skip to content

Commit

Permalink
Merge pull request #12 from atsign-company/cpswan-smarter-shepherd
Browse files Browse the repository at this point in the history
  • Loading branch information
gkc authored Aug 12, 2022
2 parents 38d36cb + 4ec7416 commit 5647059
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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/)
Expand All @@ -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:
...
Expand All @@ -46,6 +55,7 @@ A Docker swarm service for automatically updating your services whenever their b
placement:
constraints:
- node.role == manager
```
### Configuration
Expand Down
9 changes: 6 additions & 3 deletions shepherd
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5647059

Please sign in to comment.