Expand description
Worker spawner abstraction for process management
This module re-exports the spawner infrastructure from hyprstream-rpc
and provides compatibility aliases for backward compatibility.
§Architecture
ProcessSpawner (wrapper with auto-detection)
├── StandaloneBackend
│ └── tokio::process::Command
│ └── .kill_on_drop(true) for cleanup
│
└── SystemdBackend
└── systemd-run --user (or system)
└── Spawns as transient unit in hyprstream-workers.slice§Usage
ⓘ
use hyprstream_workers::runtime::spawner::{ProcessSpawner, ProcessConfig};
// Auto-detect best backend (systemd if available)
let spawner = ProcessSpawner::new();
// Spawn a daemon
let config = ProcessConfig::new("nydusd", "/usr/bin/nydusd")
.args(["--config", "/etc/nydusd.json"])
.working_dir("/var/run/hyprstream");
let process = spawner.spawn(config).await?;
println!("Spawned: {:?}", process.id());
// Later, stop the daemon
spawner.stop(&process).await?;Structs§
- Process
Config - Configuration for spawning a daemon process.
- Process
Spawner - Unified process spawner.
- Service
Spawner - Unified service spawner.
- Spawned
Process - Represents a spawned process.
- Spawned
Service - Handle for a spawned service.
- Standalone
Backend - Standalone process spawner backend.
- Systemd
Backend - Systemd spawner backend using transient units.
Enums§
- Process
Backend - Backend type for process spawning.
- Process
Kind - Type of spawned process.
- Service
Kind - Kind of spawned service (determines cleanup behavior).
- Service
Mode - Mode for spawning services.
Traits§
- Spawnable
- Trait for services that can be spawned by ServiceSpawner.
- Spawner
Backend - Trait for process spawning backends.
- Worker
Spawner - Alias for
SpawnerBackend(backward compatibility)
Functions§
- create_
spawner - Create the appropriate spawner based on system capabilities.
- create_
spawner_ of_ type - Create a spawner with explicit type selection.
Type Aliases§
- Daemon
Config - Alias for
ProcessConfig(backward compatibility)