From f1c2a7dbb322a0e2de0cc689638e7d1076f534c4 Mon Sep 17 00:00:00 2001 From: Kevin Baensch Date: Wed, 18 Jan 2023 10:12:23 +0100 Subject: [PATCH] Update docker event query to filter events. --- script/hostman.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/script/hostman.sh b/script/hostman.sh index f7dd1c8..0da4819 100755 --- a/script/hostman.sh +++ b/script/hostman.sh @@ -38,16 +38,16 @@ update_templates() { # Initial Generation update_templates -# cannot filter because reailine no longer recognized lines otherwise (check how IFS changes) -query_docker "events" | while true +LAST_CHECK="$(date +%s)" +while true do + EVENTS="" printf '%s | Listening for docker events\n' "$(get_date)" - read -r; - # wait for related events to finish - printf '%s | Waiting for event messages to settle.\n' "$(get_date)" - while [ $? -eq 0 ] + while [ -z "${EVENTS}" ] do - read -t 8 -r + NEXT_CHECK="$(($(date +%s) + 5))" + EVENTS=$(query_docker 'events' "?since=${LAST_CHECK}&until=${NEXT_CHECK}&filters={%22event%22:[%22die%22,%22kill%22,%22oom%22,%22pause%22,%22restart%22,%22start%22,%22stop%22,%22unpause%22,%22update%22]}") + LAST_CHECK="${NEXT_CHECK}" done printf '%s | Checking for changes in container label list.\n' "$(get_date)" update_templates