Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install a SIGTERM handler in addition to SIGINT #1246

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cms/io/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions cmsranking/RankingWebServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import pprint
import re
import shutil
import signal
import time
from datetime import datetime

Expand Down Expand Up @@ -622,6 +623,10 @@
certfile=config.https_certfile, keyfile=config.https_keyfile)
servers.append(https_server)

def sigterm_handler(*_):
raise KeyboardInterrupt

Check warning on line 627 in cmsranking/RankingWebServer.py

View check run for this annotation

Codecov / codecov/patch

cmsranking/RankingWebServer.py#L627

Added line #L627 was not covered by tests
signal.signal(signal.SIGTERM, sigterm_handler)

try:
gevent.joinall(list(gevent.spawn(s.serve_forever) for s in servers))
except KeyboardInterrupt:
Expand Down
Loading