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

cli: fix graceful shutdown of start-scheduler #629

Merged
merged 1 commit into from
Sep 26, 2023
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 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

Check warning on line 12 in reana_server/cli.py

View check run for this annotation

Codecov / codecov/patch

reana_server/cli.py#L12

Added line #L12 was not covered by tests

import click
from reana_commons.config import REANA_LOG_FORMAT, REANA_LOG_LEVEL
Expand All @@ -21,5 +22,12 @@
"""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

Check warning on line 28 in reana_server/cli.py

View check run for this annotation

Codecov / codecov/patch

reana_server/cli.py#L26-L28

Added lines #L26 - L28 were not covered by tests

signal.signal(signal.SIGTERM, stop_scheduler)

Check warning on line 30 in reana_server/cli.py

View check run for this annotation

Codecov / codecov/patch

reana_server/cli.py#L30

Added line #L30 was not covered by tests

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