Skip to content
Merged
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
10 changes: 2 additions & 8 deletions src/vlei/app/shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
class GracefulShutdownDoer(doing.Doer):
"""
Shuts all Agency agents down before exiting the Doist loop, performing a graceful shutdown.
Sets up signal handlers in the Doer.enter lifecycle method and exits the Doist scheduler loop in Doer.exit
Checks for the signals in the Doer.recur lifecycle method.
Sets up signal handler in the Doer.enter lifecycle method and exits the Doist scheduler loop in Doer.exit
Checks for the shutdown flag in the Doer.recur lifecycle method.
"""
def __init__(self, doist, **kwa):
"""
Expand All @@ -27,19 +27,13 @@ def handle_sigterm(self, signum, frame):
logger.info(f"Received SIGTERM, initiating graceful shutdown.")
self.shutdown_received = True

def handle_sigint(self, signum, frame):
"""Handler function for SIGINT"""
logger.info(f"Received SIGINT, initiating graceful shutdown.")
self.shutdown_received = True

def enter(self):
"""
Sets up signal handlers.
Lifecycle method called once when the Doist running this Doer enters the context for this Doer.
"""
# Register signal handler
signal.signal(signal.SIGTERM, self.handle_sigterm)
signal.signal(signal.SIGINT, self.handle_sigint)
logger.info("Registered signal handlers for SIGTERM and SIGINT")

def recur(self, tock=0.0):
Expand Down
Loading