2026-01-07 15:33:32 +01:00
2026-01-07 15:28:25 +01:00
2026-01-07 15:25:53 +01:00
2026-01-07 14:12:56 +01:00
2026-01-07 14:12:56 +01:00
2026-01-07 14:12:56 +01:00
2026-01-07 15:33:32 +01:00
2026-01-07 15:33:32 +01:00
2026-01-07 15:25:53 +01:00

noprocess

A lightweight Rust library for managing long-running processes with graceful shutdown, restart capabilities, and error handling.

demo

Designed to work with nocontrol for distributed orchestration of Rust workloads — think Kubernetes pods, but for native Rust code.

Usage

use noprocess::{Process, ProcessHandler, ProcessManager, ProcessResult};
use tokio_util::sync::CancellationToken;

struct MyPipeline;

impl ProcessHandler for MyPipeline {
    fn call(&self, cancel: CancellationToken) -> impl Future<Output = ProcessResult> + Send {
        async move {
            loop {
                tokio::select! {
                    _ = cancel.cancelled() => break,
                    _ = do_work() => {}
                }
            }
            Ok(())
        }
    }
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let manager = ProcessManager::new();

    let id = manager.add_process(Process::new(MyPipeline)).await;
    manager.start_process(&id).await?;

    // Later: stop, restart, or kill
    manager.stop_process(&id).await?;
    Ok(())
}

Features

  • Graceful shutdown — processes receive a cancellation token and can clean up
  • Configurable timeouts — force-kill stubborn processes after a deadline
  • Auto-restart — optionally restart processes that complete successfully
  • Error callbacks — handle failures and panics with custom logic
  • Process lifecycle — start, stop, restart, kill individual processes

Examples

cargo run --bin simple          # Basic start/stop/restart
cargo run --bin pipeline        # Data pipeline with backpressure
cargo run --bin worker          # Worker pool pattern

License

MIT

Description
No description provided
Readme MIT 4.1 MiB
Languages
Rust 100%