Skip to content

Commit

Permalink
cli: fix graceful shutdown of start-scheduler
Browse files Browse the repository at this point in the history
Handle SIGTERM in `start-scheduler` to gracefully stop consuming
the workflow submission queue.

Closes reanahub/reana-job-controller#347
  • Loading branch information
mdonadoni committed Sep 26, 2023
1 parent 7e84d56 commit 9326dda
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Version 0.9.1 (UNRELEASED)
- Fixes GitLab integration to automatically redirect the user to the correct URL when the access request is accepted.
- Fixes authentication flow to correctly deny access to past revoked tokens in case the same user has also other new active tokens.
- Fixes the email templates to show the correct ``kubectl`` commands when REANA is deployed inside a non-default namespace or with a custom component name prefix.
- Fixes ``start-scheduler`` command to gracefully stop when being terminated.
- Adds logic to support SSO with third-party Keycloak authentication services to ``config.py``.

Version 0.9.0 (2023-01-19)
Expand Down
8 changes: 8 additions & 0 deletions reana_server/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""REANA Server command line tool."""

import logging
import signal

import click
from reana_commons.config import REANA_LOG_FORMAT, REANA_LOG_LEVEL
Expand All @@ -21,5 +22,12 @@ def start_scheduler():
"""Start a workflow execution scheduler process."""
logging.basicConfig(level=REANA_LOG_LEVEL, format=REANA_LOG_FORMAT, force=True)
scheduler = WorkflowExecutionScheduler()

def stop_scheduler(signum, frame):
logging.info("Stopping scheduler...")
scheduler.should_stop = True

signal.signal(signal.SIGTERM, stop_scheduler)

logging.info("Starting scheduler...")
scheduler.run()

0 comments on commit 9326dda

Please sign in to comment.