From de76ebe884558c6ba54c6b8a65de030513b732a8 Mon Sep 17 00:00:00 2001 From: jschaul Date: Fri, 2 Feb 2024 15:55:33 +0100 Subject: [PATCH] fixup pre-stop-hook bug: account for multiple allocation metrics --- docker/coturn/wireapp/pre-stop-hook.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docker/coturn/wireapp/pre-stop-hook.sh b/docker/coturn/wireapp/pre-stop-hook.sh index d8d34d34d..a6f9a8a2d 100644 --- a/docker/coturn/wireapp/pre-stop-hook.sh +++ b/docker/coturn/wireapp/pre-stop-hook.sh @@ -25,7 +25,16 @@ while true; do echo "No more active allocations, exiting" exit 0 fi - if [ "$allocs" = 0 ]; then + + # Note: there can be multiple allocation counts, e.g. + # turn_total_allocations{type="UDP"} 0 + # turn_total_allocations{type="TCP"} 0 + # So we need to sum the counts before comparing with 0. + sum=0 + for num in $allocs; do + (( sum += num )) + done + if [ "$sum" = 0 ]; then echo "No more active allocations, exiting" exit 0 fi