Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add hostname to output #11

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions shepherd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ update_services() {
local no_resolve_image_flag=""
local name
local apprise_sidecar_url="${APPRISE_SIDECAR_URL:-}"
local hostname
hostname="${HOSTNAME:-$(hostname)}"

[ "$supports_detach_option" = true ] && detach_option="--detach=false"
[ "$supports_registry_auth" = true ] && registry_auth="--with-registry-auth"
Expand All @@ -53,13 +55,13 @@ update_services() {
logger "Trying to update service $name with image $image" "true"

if ! docker service update "$name" $detach_option $registry_auth $no_resolve_image_flag --image="$image" > /dev/null; then
logger "Service $name update failed!"
logger "Service $name update failed on $hostname!"
if [[ "${ROLLBACK_ON_FAILURE+x}" ]]; then
logger "Rolling $name back"
docker service update "$name" $detach_option $registry_auth $no_resolve_image_flag --rollback > /dev/null
fi
if [[ "$apprise_sidecar_url" != "" ]]; then
title="[Shepherd] Service $name update failed"
title="[Shepherd] Service $name update failed on $hostname"
body="$(date) Service $name failed to update to $(docker service inspect "$name" -f '{{.Spec.TaskTemplate.ContainerSpec.Image}}')"
curl -X POST -H "Content-Type: application/json" --data "{\"title\": \"$title\", \"body\": \"$body\"}" "$apprise_sidecar_url"
fi
Expand All @@ -73,7 +75,7 @@ update_services() {
else
logger "Service $name was updated!"
if [[ "$apprise_sidecar_url" != "" ]]; then
title="[Shepherd] Service $name updated"
title="[Shepherd] Service $name updated on $hostname"
body="$(date) Service $name was updated from $previousImage to $currentImage"
curl -X POST -H "Content-Type: application/json" --data "{\"title\": \"$title\", \"body\": \"$body\"}" "$apprise_sidecar_url"
fi
Expand Down