Module actix_web::actix::signal [−][src]
An actor implementation of Unix signal handling
This module implements asynchronous signal handling for Actix. For each
signal ProcessSignals
actor sends Signal
message to all subscriber. To
subscriber, send Subscribe
message to ProcessSignals
actor.
Examples
use actix::actors::signal; use actix::prelude::*; struct Signals; impl Actor for Signals { type Context = Context<Self>; } // Shutdown system on and of `SIGINT`, `SIGTERM`, `SIGQUIT` signals impl Handler<signal::Signal> for Signals { type Result = (); fn handle(&mut self, msg: signal::Signal, _: &mut Context<Self>) { match msg.0 { signal::SignalType::Int => { println!("SIGINT received, exiting"); System::current().stop(); } signal::SignalType::Hup => { println!("SIGHUP received, reloading"); } signal::SignalType::Term => { println!("SIGTERM received, stopping"); System::current().stop(); } signal::SignalType::Quit => { println!("SIGQUIT received, exiting"); System::current().stop(); } _ => (), } } } fn main() { // initialize system System::run(|| { // Start signals handler let addr = Signals.start(); // send SIGTERM std::thread::spawn(move || { // emulate SIGNTERM addr.do_send(signal::Signal(signal::SignalType::Term)); }); }); std::process::exit(0); }
Structs
DefaultSignalsHandler |
Default signals handler. This actor sends |
ProcessSignals |
An actor implementation of Unix signal handling |
Signal |
Process signal message |
Subscribe |
Subscribe to process signals. |
Enums
SignalType |
Different types of process signals |