From 587b38a125d8f66d28d3eed9935a6c607607e156 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 13 Apr 2019 13:25:12 +0200 Subject: add check if nginx is running before trying to terminate --- src/benchmarks/httpd.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/benchmarks/httpd.py b/src/benchmarks/httpd.py index 6352217..2bc0ce5 100644 --- a/src/benchmarks/httpd.py +++ b/src/benchmarks/httpd.py @@ -32,13 +32,15 @@ class Benchmark_HTTPD(Benchmark): super().__init__() def terminate_server(self): - ret = subprocess.run(server_cmd + ["-s", "stop"], stdout=PIPE, - stderr=PIPE, universal_newlines=True) - - if ret.returncode != 0: - print_debug("Stdout:", ret.stdout) - print_debug("Stderr:", ret.stderr) - raise Exception("Stopping {} failed with {}".format(server_cmd[0], ret.returncode)) + # check if nginx is running + if os.path.isfile(os.path.join(builddir, "nginx", "nginx.pid")): + ret = subprocess.run(server_cmd + ["-s", "stop"], stdout=PIPE, + stderr=PIPE, universal_newlines=True) + + if ret.returncode != 0: + print_debug("Stdout:", ret.stdout) + print_debug("Stderr:", ret.stderr) + raise Exception("Stopping {} failed with {}".format(server_cmd[0], ret.returncode)) def preallocator_hook(self, allocator, run, env, verbose): actual_cmd = allocator[1]["cmd_prefix"].split() + server_cmd -- cgit v1.2.3