diff --git a/eval.py b/eval.py index 52f3d3f1a6716154f82c1f6ef8111c0f3ceee78a..d0a9c8fa1b704536691114965a6a5718231e6dec 100755 --- a/eval.py +++ b/eval.py @@ -367,7 +367,7 @@ TERMINATION_TIME = 10 CLIENT_SEPARATION_TIME = 10 TERMINATION_CMD = 'nc {host} 12345' -SERVER_KILL_CMD = 'pkill -9 {proc}' +SERVER_KILL_CMD = 'pkill -9 -f {proc}' def write_desc(data_dir): @@ -582,40 +582,39 @@ def prepare_emper_flavors(flavors): build_env=desc.get('build_env', {})) -def shutdown_server(server: subprocess.Popen): +def shutdown_server(server: str, proc: subprocess.Popen): """Terminate a running sever command""" # server is not running - if server.poll() is not None: + if proc.poll() is not None: return termination_cmd = TERMINATION_CMD.format(host=HOST) # try to shutdown by sending "quit" to the server try: - subprocess.run(termination_cmd.split(), input=b'quit\n', check=True) + subprocess.run(termination_cmd.split(), + input=b'quit\n', + check=True, + timeout=TERMINATION_TIME) + # wait for the server to terminate + proc.wait(TERMINATION_TIME) + return + except subprocess.CalledProcessError as run_err: log.warning('%s terminated unsuccessful: %s', termination_cmd, run_err) - # wait for the server to terminate - try: - server.wait(TERMINATION_TIME) - return - except subprocess.TimeoutExpired: - pass + except subprocess.TimeoutExpired as timeout_err: + log.warning('%s termination timeout: %s', termination_cmd, timeout_err) # kill the server using pkill(1) -9 kill_cmd = '' if REMOTE_CMD: kill_cmd += REMOTE_CMD.format(host=HOST, ssh_port=SSH_PORT) + ' ' - if isinstance(server.args, list): - server_bin = server.args[0] - elif isinstance(server.args, str): - server_bin = server.args.split()[0] - + server_bin = SERVER_CMDS[server].split()[0] kill_cmd += SERVER_KILL_CMD.format(proc=server_bin) cmd_run(kill_cmd, check=False) - server.wait(TERMINATION_TIME) + proc.wait(TERMINATION_TIME) class BenchResult(Enum): @@ -784,7 +783,7 @@ def bench() -> Dict[str, List[List[BenchResult]]]: sleep(CLIENT_SEPARATION_TIME) - shutdown_server(server_popen) + shutdown_server(server, server_popen) return results