Skip to main content

Module signals

Module signals 

Source
Expand description

Unix signal handling for graceful shutdown and configuration reload

Provides a signal coordinator that handles:

  • SIGTERM / SIGINT: Graceful shutdown
  • SIGHUP: Configuration reload

§Architecture

The coordinator uses broadcast channels to notify multiple listeners about signal events. This allows different parts of the application to respond to shutdown or reload requests independently.

§Example

ⓘ
use hyprstream::systemd::SignalCoordinator;

#[tokio::main]
async fn main() {
    let coordinator = SignalCoordinator::new();

    // Get shutdown receiver before spawning
    let mut shutdown_rx = coordinator.shutdown_receiver();

    // Spawn signal handler
    let signal_handle = tokio::spawn(async move {
        coordinator.run().await;
    });

    // Your application logic here...

    // Wait for shutdown signal
    let _ = shutdown_rx.recv().await;
    println!("Shutting down gracefully...");
}

Structs§

SignalCoordinator
Coordinates Unix signal handling across the application

Enums§

SignalEvent
Signal events that can be received

Functions§

shutdown_signal
Create a simple shutdown future that completes on SIGTERM/SIGINT