A lightweight process supervisor and daemon written in Zig for managing and monitoring multiple child processes.
Educational Project: This is a learning project exploring systems programming concepts in Zig including process management, IPC, and concurrent programming.
ZPM is a process supervisor similar to Supervisor or PM2. It runs as a daemon, managing child processes and automatically restarting them if they crash.
- Auto-restart crashed processes (up to 5 attempts)
- Process logging (stdout/stderr to separate files)
- CLI interface:
start,stop,status,logs - Unix socket IPC communication
- Thread-safe concurrent process management
- Zig 0.16.0-dev.624 or higher
Create a config.toml file:
version = "0.1.0"
[[processes]]
name = "web-server"
command = "python3"
args = ["-m", "http.server", "8080"]
type = "web"# Start daemon
./zig-out/bin/zpm start --config config.toml --foreground
# Check status
./zig-out/bin/zpm status
# Stop daemon
./zig-out/bin/zpm stop
# View logs
tail -f child0.stdout.log- Multi-threaded: Main thread + IPC server + supervisor thread per process
- Auto-restart: Supervisor monitors each process, restarts on crash (max 5 attempts, 2s delay)
- IPC: Unix socket at
/tmp/zpm.sockfor CLI communication - Logging: Separate stdout/stderr log files per process
src/
├── main.zig # CLI entry point
├── supervisor.zig # Process monitoring & restart
├── state.zig # Thread-safe state management
├── daemon.zig # Daemonization & PID handling
├── config.zig # TOML config parsing
└── ipc.zig # Unix socket IPC server
Omar Sabra (the-sabra)