taler-mdb

GNU Taler Extensions and Integrations
Log | Files | Refs | Submodules | README | LICENSE

commit 4dba7559104d0fbd2eae364a848d118da51d10f8
parent 782e22177f7f630c27fc88115abe7b959ef94bd7
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Sun, 14 Jan 2024 17:38:56 +0100

bugfixes in network monitor script

Diffstat:
Mcontrib/taler-mdb-network-check.sh | 36++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/contrib/taler-mdb-network-check.sh b/contrib/taler-mdb-network-check.sh @@ -29,6 +29,7 @@ set -eu EXIT_STATUS=0 CHILD_PID=-1 +ERROR_PID=-1 # Exit, with error message (hard failure) function exit_fail() { @@ -86,6 +87,13 @@ function cleanup() # Failure. Stop our child (if any) and show it. function show_failure() { + echo "Showing failure $1" + if [ "$ERROR_PID" != "-1" ] + then + kill -TERM "$ERROR_PID" + wait + ERROR_PID="-1" + fi if [ "$CHILD_PID" != "-1" ] then kill -TERM "$CHILD_PID" @@ -93,14 +101,20 @@ function show_failure() CHILD_PID="-1" fi ${FAIL_PROG} "$1" >&2 & - CHILD_PID=$! + ERROR_PID=$! } # Function to run when our child died. function childdeath() { + if [ "$ERROR_PID" != "-1" ] + then + wait ${ERROR_PID} + ERROR_PID="-1" + fi if [ "$CHILD_PID" != "-1" ] then + echo "taler-mdb died" wait ${CHILD_PID} CHILD_PID="-1" show_failure child-died @@ -169,22 +183,28 @@ function check_network() return fi - if [ "$CHILD_PID" != "-1" ] + echo "Network OK" + if [ "$ERROR_PID" != "-1" ] then - kill -TERM "$CHILD_PID" + kill -TERM "$ERROR_PID" wait - CHILD_PID="-1" + ERROR_PID="-1" + fi + + if [ "$CHILD_PID" = "-1" ] + then + echo "Starting child using $@" + # shellcheck disable=SC2068 + $@ & + CHILD_PID=$! fi - echo "Network OK, starting child" - # shellcheck disable=SC2068 - $@ & - CHILD_PID=$! } # Check network status while true do + echo "Checking network status" check_network sleep 30 done