server: handle signals during startup

previously, the signal handler would ignore SIGINTs and SIGTERMs during
server startup, so if there would be e.g. non-respoinding hardware, the
program could not be exited until a timeout occured.

For now, the default signal handler will be called. Later, we should
consider cleaning up the partial started modules.

Change-Id: I5bb802b5d996bb03dfa2679c1497e298fde1dd17
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32247
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
Alexander Zaft
2023-10-04 10:28:13 +02:00
parent 4b5e02c957
commit c68529d42d

View File

@ -108,9 +108,13 @@ class Server:
signal.signal(signal.SIGINT, self.signal_handler)
signal.signal(signal.SIGTERM, self.signal_handler)
def signal_handler(self, _num, _frame):
def signal_handler(self, num, frame):
if hasattr(self, 'interface') and self.interface:
self.shutdown()
else:
# TODO: we should probably clean up the already initialized modules
# when getting an interrupt while the server is starting
signal.default_int_handler(num, frame)
def start(self):
if not DaemonContext: