Skip to main content

Module spawner

Module spawner 

Source
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§

ProcessConfig
Configuration for spawning a daemon process.
ProcessSpawner
Unified process spawner.
ServiceSpawner
Unified service spawner.
SpawnedProcess
Represents a spawned process.
SpawnedService
Handle for a spawned service.
StandaloneBackend
Standalone process spawner backend.
SystemdBackend
Systemd spawner backend using transient units.

Enums§

ProcessBackend
Backend type for process spawning.
ProcessKind
Type of spawned process.
ServiceKind
Kind of spawned service (determines cleanup behavior).
ServiceMode
Mode for spawning services.

Traits§

Spawnable
Trait for services that can be spawned by ServiceSpawner.
SpawnerBackend
Trait for process spawning backends.
WorkerSpawner
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§

DaemonConfig
Alias for ProcessConfig (backward compatibility)