warpdrive_proxy/process/mod.rs
1//! Process management and supervision
2//!
3//! This module provides process supervision capabilities for managing
4//! upstream application servers. It handles spawning, monitoring, signal
5//! forwarding, and graceful shutdown of child processes.
6//!
7//! # Overview
8//!
9//! The main component is `ProcessSupervisor`, which:
10//! - Spawns child processes with environment configuration
11//! - Monitors process health and exit status
12//! - Forwards signals (SIGTERM/SIGINT) to child processes
13//! - Implements graceful shutdown with configurable timeout
14//!
15//! # Example
16//!
17//! ```no_run
18//! use warpdrive::process::ProcessSupervisor;
19//! use anyhow::Result;
20//!
21//! #[tokio::main]
22//! async fn main() -> Result<()> {
23//! // Create supervisor for a Rails application
24//! let supervisor = ProcessSupervisor::new(
25//! "bundle".to_string(),
26//! vec!["exec".to_string(), "puma".to_string()],
27//! );
28//!
29//! // Start the process with PORT=3000
30//! supervisor.start(3000).await?;
31//!
32//! // Handle signals in background
33//! let signal_handle = tokio::spawn({
34//! let supervisor = supervisor.clone();
35//! async move {
36//! supervisor.handle_signals().await;
37//! }
38//! });
39//!
40//! // Wait for process to exit
41//! let exit_code = supervisor.wait().await?;
42//!
43//! // Clean up
44//! signal_handle.abort();
45//!
46//! std::process::exit(exit_code);
47//! }
48//! ```
49
50mod supervisor;
51
52pub use supervisor::ProcessSupervisor;