From: Thomas D Date: Fri, 13 Feb 2015 12:33:23 +0000 (+0100) Subject: When test service startup timeout was reached kill (cleanup) still running test services X-Git-Tag: dnsdist-1.0.0-alpha1~285^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4fbe0e8ca0ff1515c97c9290118d413c498e4936;p=pdns When test service startup timeout was reached kill (cleanup) still running test services If curl for example isn't installed or fails to check the service status for any reason, we need to kill the test service if still running to prevent any resource leak. --- diff --git a/modules/remotebackend/testrunner.sh b/modules/remotebackend/testrunner.sh index 079750e30..6b0650491 100755 --- a/modules/remotebackend/testrunner.sh +++ b/modules/remotebackend/testrunner.sh @@ -39,6 +39,13 @@ function start_web() { let timeout=timeout+1 done + if kill -0 ${webrick_pid} 2>/dev/null; then + # if something is wrong with curl (i.e. curl isn't installed, localhost is firewalled ...) + # the status check will fail -- cleanup required! + echo >&2 "WARNING: Timeout (${timeout}s) reached: \"${1}\" test service process is running but status check failed" + kill -KILL ${webrick_pid} 2>/dev/null + fi + echo >&2 "ERROR: A timeout (${timeout}s) was reached while waiting for \"${1}\" test service to start!" echo >&2 " See \"modules/remotebackend/${service_logfile}\" for more details." exit 69 @@ -98,6 +105,12 @@ function start_zeromq() { let timeout=timeout+1 done + if kill -0 ${zeromq_pid} 2>/dev/null; then + # not sure when this can happen but we should cleanup any process we started + echo >&2 "WARNING: Timeout (${timeout}s) reached: \"ZeroMQ\" test service process is running but status check failed" + kill -KILL ${zeromq_pid} 2>/dev/null + fi + echo >&2 "ERROR: A timeout (${timeout}s) was reached while waiting for \"ZeroMQ\" test service to start!" echo >&2 " See \"modules/remotebackend/${service_logfile}\" for more details." exit 69 @@ -155,6 +168,12 @@ function start_unix() { let timeout=timeout+1 done + if kill -0 ${socat_pid} 2>/dev/null; then + # not sure when this can happen but we should cleanup any process we started + echo >&2 "WARNING: Timeout (${timeout}s) reached: \"UNIX socket\" test service process is running but status check failed" + kill -KILL ${socat_pid} 2>/dev/null + fi + echo >&2 "ERROR: A timeout (${timeout}s) was reached while waiting for \"UNIX socket\" test service to start!" exit 69 }