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