1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! # modo::runtime
//!
//! Graceful shutdown runtime for modo applications.
//!
//! Provides three composable building blocks for orderly process teardown:
//!
//! - [`Task`] — a trait for any service that can be shut down asynchronously.
//! - [`wait_for_shutdown_signal`] — async function that resolves on `SIGINT`
//! (Ctrl+C) or, on Unix, `SIGTERM`.
//! - [`run!`](crate::run) — macro that waits for a signal and then calls
//! [`Task::shutdown`] on each supplied value in declaration order.
//!
//! ## Quick start
//!
//! ```rust,no_run
//! use modo::runtime::Task;
//! use modo::Result;
//!
//! struct MyServer;
//!
//! impl Task for MyServer {
//! async fn shutdown(self) -> Result<()> {
//! // perform graceful shutdown
//! Ok(())
//! }
//! }
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let server = MyServer;
//! modo::run!(server).await
//! }
//! ```
//!
//! ### Using `wait_for_shutdown_signal` directly
//!
//! ```rust,no_run
//! use modo::runtime::wait_for_shutdown_signal;
//!
//! #[tokio::main]
//! async fn main() {
//! wait_for_shutdown_signal().await;
//! println!("shutting down...");
//! }
//! ```
pub use wait_for_shutdown_signal;
pub use Task;