Expand description
Process management and supervision
This module provides process supervision capabilities for managing upstream application servers. It handles spawning, monitoring, signal forwarding, and graceful shutdown of child processes.
§Overview
The main component is ProcessSupervisor, which:
- Spawns child processes with environment configuration
- Monitors process health and exit status
- Forwards signals (SIGTERM/SIGINT) to child processes
- Implements graceful shutdown with configurable timeout
§Example
use warpdrive::process::ProcessSupervisor;
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
// Create supervisor for a Rails application
let supervisor = ProcessSupervisor::new(
"bundle".to_string(),
vec!["exec".to_string(), "puma".to_string()],
);
// Start the process with PORT=3000
supervisor.start(3000).await?;
// Handle signals in background
let signal_handle = tokio::spawn({
let supervisor = supervisor.clone();
async move {
supervisor.handle_signals().await;
}
});
// Wait for process to exit
let exit_code = supervisor.wait().await?;
// Clean up
signal_handle.abort();
std::process::exit(exit_code);
}Structs§
- Process
Supervisor - Process supervisor for managing upstream application servers