Skip to content

Commit f60bfb8

Browse files
committed
Support SIGTERM to stop server gracefully.
Fixes #9.
1 parent b45e111 commit f60bfb8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

atest/tests/stopping.robot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ SIGINT
1313
SIGHUP
1414
Send Signal To Process SIGHUP
1515

16+
SIGTERM
17+
Send Signal To Process SIGTERM
18+
1619
*** Keywords ***
1720
Start Server
1821
Start And Import Remote Library basics.py ${TEST NAME}

src/robotremoteserver.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ def stop_with_signal(signum, frame):
6363
self._allow_stop = True
6464
self.stop_remote_server()
6565
raise KeyboardInterrupt
66-
if hasattr(signal, 'SIGHUP'):
67-
signal.signal(signal.SIGHUP, stop_with_signal)
68-
if hasattr(signal, 'SIGINT'):
69-
signal.signal(signal.SIGINT, stop_with_signal)
66+
for name in 'SIGINT', 'SIGTERM', 'SIGHUP':
67+
if hasattr(signal, name):
68+
signal.signal(getattr(signal, name), stop_with_signal)
7069

7170
def _announce_start(self, port_file=None):
7271
host, port = self.server_address

0 commit comments

Comments
 (0)