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 21, 2023
1 parent a339846 commit 6c163a0
Showing 1 changed file with 8 additions and 0 deletions.
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 6c163a0

Please sign in to comment.