Skip to content

Review shutdown process for all tasks/jobs #1588

@josecelano

Description

@josecelano

Relates to: #1587

I've implemented a centralised shutdown for event listeners here.

The Torrust Tracker starts many jobs, most of which were handled independently. That means:

  • There was no way to control them from the main app.
  • They listed directly for the CRTl+c signal.

Not I'm refactoring the application to:

  • Centralise job management in the JobManager type.
  • Capture the CTRL+c signal only by the main app, and the main app decides which job and when to shutdown.

This allows implementing centralised policies to handle jobs.

There are still some jobs that handle the CTRL+c signal directly:

  • HTTP servers using axum: torrust_server_lib::signals::global_shutdown_signal
  • Job to update metrics: torrust_tracker_swarm_coordination_registry::statistics::activity_metrics_updater::start_job
  • Torrent cleanup jonb: torrust_tracker_lib::bootstrap::jobs::torrent_cleanup::start_job

We should pass the cancellation token.

cc @da2ce7

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions