-
-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathdocker_warning_heartbeat
More file actions
executable file
·47 lines (41 loc) · 1004 Bytes
/
Copy pathdocker_warning_heartbeat
File metadata and controls
executable file
·47 lines (41 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
set -eu
report=${WEBLATE_DOCKER_WARNING_REPORT:-}
hostname=${WEBLATE_DOCKER_WARNING_HOSTNAME:-unknown}
service=${WEBLATE_DOCKER_WARNING_SERVICE:-all}
warnings=${WEBLATE_DOCKER_WARNING_MESSAGES:-}
sleep_pid=
if [ -z "$report" ]; then
exit 0
fi
initialize_report() {
mkdir -p "$report"
printf '%s\n' "$hostname" > "$report/hostname"
printf '%s\n' "$service" > "$report/service"
printf '%s' "$warnings" > "$report/warnings"
touch "$report/heartbeat" "$report"
}
cleanup_report() {
if [ -n "$sleep_pid" ]; then
kill "$sleep_pid" 2> /dev/null || true
fi
rm -f -- \
"$report/heartbeat" \
"$report/hostname" \
"$report/service" \
"$report/warnings" || true
rmdir -- "$report" 2> /dev/null || true
}
shutdown() {
cleanup_report
exit 0
}
trap shutdown HUP INT TERM
initialize_report
while :; do
touch "$report/heartbeat" "$report"
sleep 60 &
sleep_pid=$!
wait "$sleep_pid"
sleep_pid=
done