Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
i4
manycore
emper-io-eval
Commits
06a67084
Commit
06a67084
authored
Aug 27, 2021
by
Florian Fischer
Browse files
[eval.py] fix killing a server not properly terminating
parent
d5b51805
Changes
1
Hide whitespace changes
Inline
Side-by-side
eval.py
View file @
06a67084
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment