torrust-tracker
torrust-tracker copied to clipboard
Review shutdown process for all tasks/jobs
Relates to: https://github.com/torrust/torrust-tracker/pull/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
JobManagertype. - 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