diff --git a/cms/io/service.py b/cms/io/service.py index 3ba62aa81..c93d10339 100644 --- a/cms/io/service.py +++ b/cms/io/service.py @@ -78,6 +78,7 @@ class Service: def __init__(self, shard=0): signal.signal(signal.SIGINT, lambda unused_x, unused_y: self.exit()) + signal.signal(signal.SIGTERM, lambda unused_x, unused_y: self.exit()) self.name = self.__class__.__name__ self.shard = shard diff --git a/cmsranking/RankingWebServer.py b/cmsranking/RankingWebServer.py index 64eb73363..4b616af7b 100755 --- a/cmsranking/RankingWebServer.py +++ b/cmsranking/RankingWebServer.py @@ -24,6 +24,7 @@ import pprint import re import shutil +import signal import time from datetime import datetime @@ -622,6 +623,10 @@ def main(): certfile=config.https_certfile, keyfile=config.https_keyfile) servers.append(https_server) + def sigterm_handler(*_): + raise KeyboardInterrupt + signal.signal(signal.SIGTERM, sigterm_handler) + try: gevent.joinall(list(gevent.spawn(s.serve_forever) for s in servers)) except KeyboardInterrupt: