mirror of
https://github.com/willfarrell/docker-autoheal.git
synced 2024-12-06 19:16:20 +01:00
Notify webhooks using a generic URL
This commit is contained in:
+1
-2
@@ -11,8 +11,7 @@ ENV AUTOHEAL_CONTAINER_LABEL=autoheal \
|
||||
AUTOHEAL_DEFAULT_STOP_TIMEOUT=10 \
|
||||
DOCKER_SOCK=/var/run/docker.sock \
|
||||
CURL_TIMEOUT=30 \
|
||||
WEBHOOK_SLACK="" \
|
||||
WEBHOOK_TEAMS=""
|
||||
WEBHOOK_URL=""
|
||||
|
||||
HEALTHCHECK --interval=5s CMD pgrep -f autoheal || exit 1
|
||||
|
||||
|
||||
@@ -60,8 +60,7 @@ AUTOHEAL_START_PERIOD=0 # wait 0 seconds before first health check
|
||||
AUTOHEAL_DEFAULT_STOP_TIMEOUT=10 # Docker waits max 10 seconds (the Docker default) for a container to stop before killing during restarts (container overridable via label, see below)
|
||||
DOCKER_SOCK=/var/run/docker.sock # Unix socket for curl requests to Docker API
|
||||
CURL_TIMEOUT=30 # --max-time seconds for curl requests to Docker API
|
||||
WEBHOOK_SLACK="" # post message to the slack webhook if a container was restarted (or restart failed)
|
||||
WEBHOOK_TEAMS="" # post message to the teams webhook if a container was restarted (or restart failed)
|
||||
WEBHOOK_URL="" # post message to the webhook if a container was restarted (or restart failed)
|
||||
```
|
||||
|
||||
### Optional Container Labels
|
||||
|
||||
+3
-9
@@ -7,8 +7,7 @@ set -o pipefail
|
||||
DOCKER_SOCK=${DOCKER_SOCK:-/var/run/docker.sock}
|
||||
UNIX_SOCK=""
|
||||
CURL_TIMEOUT=${CURL_TIMEOUT:-30}
|
||||
WEBHOOK_TEAMS=${WEBHOOK_TEAMS:-""}
|
||||
WEBHOOK_SLACK=${WEBHOOK_SLACK:-""}
|
||||
WEBHOOK_URL=${WEBHOOK_URL:-""}
|
||||
|
||||
# only use unix domain socket if no TCP endpoint is defined
|
||||
case "${DOCKER_SOCK}" in
|
||||
@@ -62,14 +61,9 @@ notify_webhook() {
|
||||
local text="$1"
|
||||
local data="{\"text\": \"${text}\"}"
|
||||
|
||||
if [ -n "$WEBHOOK_SLACK" ]
|
||||
if [ -n "$WEBHOOK_URL" ]
|
||||
then
|
||||
curl -X POST -H "Content-type: application/json" -d $data $WEBHOOK_SLACK
|
||||
fi
|
||||
|
||||
if [ -n "$WEBHOOK_TEAMS" ]
|
||||
then
|
||||
curl -X POST -H "Content-Type: application/json" -d $data $WEBHOOK_TEAMS
|
||||
curl -X POST -H "Content-type: application/json" -d $data $WEBHOOK_URL
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user