Skip to content

Add token-aware server lifecycle API #2234

Description

@josecelano

Parent EPIC: #1488 - Overhaul: Tracker Shutdown (roadmap sequence 5, draft SI-2).

Goal

Add and release an additive torrust-server-lib shutdown-wait primitive that resolves from an injected CancellationToken without subscribing to OS signals. Update the tracker to consume that released crate version without migrating existing server consumers.

Scope

  • Implement the primitive directly in the existing torrust/torrust-server-lib clone, with deterministic token-cancellation and legacy-compatibility tests.
  • Preserve global_shutdown_signal(), shutdown_signal(), shutdown_signal_with_message(), Halted, and existing server start APIs unchanged.
  • Open, merge, and publish the focused server-lib change; then update this tracker from torrust-server-lib 0.2.0 to the exact published version.
  • Add tracker-side contract coverage confirming the new API is available while existing consumers retain their legacy paths.
  • Keep Axum drain-controller ownership and joining out of this task: SI-10 owns the joinable drain helper and SI-11 through SI-17 own individual consumer migrations.

Acceptance Criteria

  • A published torrust-server-lib version provides an additive wait primitive that resolves from an injected CancellationToken without subscribing to OS signals.
  • Existing global_shutdown_signal(), shutdown_signal(), shutdown_signal_with_message(), and Halted remain source- and behavior-compatible.
  • The new primitive does not take or expose Halted; Started startup signaling remains unaffected.
  • The tracker consumes the exact published crate version, not an unpublished Git dependency.
  • Focused server-lib tests prove token cancellation and legacy behavior; tracker coverage compiles against the new API.
  • Future-consumer guidance assigns graceful-stop controller ownership and joining to SI-10 and later component migrations.

Verification

Run server-lib formatting, Clippy, tests, and cargo publish --dry-run; then run tracker linter all, cargo machete, focused server tests, workspace documentation tests, and pre-push checks. Record release and manual cancellation evidence in the issue-local documentation.

Full reviewed specification, including ownership, commit points, manual verification, and risks: docs/issues/open/<issue-number>-1488-si-2-remove-global-shutdown-signal/ISSUE.md after promotion.

Related: #1586, #1588, #2132, #2169, #2221.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions