| Crates.io | systemg |
| lib.rs | systemg |
| version | 0.19.0 |
| created_at | 2025-02-28 02:30:38.461804+00 |
| updated_at | 2026-01-22 23:01:46.232322+00 |
| description | A simple process manager. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1572395 |
| size | 1,732,952 |
systemg is a general-purpose program composer that transforms arbitrary programs into coherent systems with explicit lifecycles, dependencies, and health monitoring. Instead of managing individual daemons or containers, it focuses on composition over mechanics—turning a collection of processes into a system you can reason about, evolve, and deploy cleanly.
Built on top of existing OS primitives like systemd and cgroups, systemg inherits their stability while adding higher-level intent: how programs relate, start, roll, and recover together.
Curious about the architecture? Read How Systemg Works for a deep dive into userspace vs. kernel-space behavior, socket activation, and runtime helpers.
Install the system binary:
$ curl --proto '=https' --tlsv1.2 -fsSL https://sh.sysg.dev/ | sh
Install systemg using cargo:
$ cargo install sysg
Or download the pre-built binary from the releases page.
For system deployments, scripts/install-systemg.sh installs /usr/bin/sysg, provisions /etc/systemg, /var/lib/systemg, /var/log/systemg, and drops sample logrotate + systemd assets for socket activation. Review and adapt it to match your distribution policies before running. Pair it with examples/system-mode.yaml and check the new docs/docs/security.md guide for hardening best practices.
Start the process manager with the default configuration:
# Start with default configuration file (systemg.yaml)
$ sysg start
# Start with a specific configuration file
$ sysg start --config systemg.yaml
# Start the long-lived supervisor (persists after you log out)
$ sysg start --config systemg.yaml --daemonize
When the supervisor is running it remains active in the background, holding service processes in the same process group so commands like sysg stop, sysg restart, sysg status, and sysg logs can coordinate them even after you disconnect from the shell that started them.
Traditional service managers focus on the mechanics of keeping processes alive. systemg takes a different approach: it's about composing programs into systems. While tools like systemd manage individual units with complex dependency chains, systemg lets you declare how programs work together as a coherent whole—with explicit lifecycles, health checks, and deployment strategies that make the system's behavior predictable and evolvable.
.env files across all composed programs.Need to manage system daemons, bind privileged ports, or attach cgroup limits? Run the supervisor in privileged mode:
# Start with elevated privileges and system-wide state directories
$ sudo sysg --sys start --config /etc/systemg/nginx.yaml --daemonize
# Bind as root, then immediately drop to the configured service user
$ sudo sysg --sys --drop-privileges start --service web
# Check status without elevated privileges (falls back to userspace mode)
$ sysg status --service web
In privileged mode systemg relocates state to /var/lib/systemg, writes supervisor logs to /var/log/systemg/supervisor.log, and respects the new service-level fields:
services:
web:
command: "./server"
user: "www-data"
group: "www-data"
supplementary_groups: ["www-logs"]
limits:
nofile: 65536
nproc: 4096
memlock: "unlimited" # supports K/M/G/T suffixes
nice: -5
cpu_affinity: [0, 1]
cgroup:
memory_max: "512M"
cpu_max: "200000 100000"
capabilities:
- CAP_NET_BIND_SERVICE
- CAP_SYS_NICE
isolation:
network: true
pid: true
mount: true
All privileged operations are opt-in: services that omit these fields continue to run unprivileged, and unit tests skip elevated scenarios automatically when not running as root.
Declare service relationships with the depends_on field to coordinate startup order and health checks. Systemg will:
For example:
version: "1"
services:
database:
command: "postgres -D /var/lib/postgres"
web:
command: "python app.py"
depends_on:
- database
If database fails to come up, web will remain stopped and log the dependency failure until the database is healthy again.
Services can opt into rolling restarts so existing instances keep serving traffic until replacements are healthy. Add a deployment block to configure the behavior:
version: "1"
services:
api:
command: "./target/release/api"
restart_policy: "always"
deployment:
strategy: "rolling" # default is "immediate"
pre_start: "cargo build --release"
health_check:
url: "http://localhost:8080/health"
timeout: "60s"
retries: 5
grace_period: "5s"
strategy — set to rolling to enable the zero-downtime workflow, or omit to keep the traditional stop/start cycle.pre_start — optional shell command executed before the new instance launches (perfect for build or migrate steps).health_check — optional HTTP probe the replacement must pass before traffic flips; configure timeout and retry budget per service.grace_period — optional delay to keep the old instance alive after the new one passes health checks, giving load balancers time to rebalance.If any rolling step fails, systemg restores the original instance and surfaces the error so unhealthy builds never replace running services.
Services can be configured to run on a cron schedule for short-lived, recurring tasks. Cron jobs are managed by the supervisor and run independently of regular services:
version: "1"
services:
backup:
command: "sh backup-script.sh"
cron:
expression: "0 0 * * * *" # Run every hour at minute 0
timezone: "America/New_York" # Optional, defaults to system timezone
Key features:
command for continuous running and a cron configuration; cron is opt-in via the cron field.Note: Cron jobs do not support restart policies, as they are designed to be short-lived tasks that complete and exit.
The sysg command-line interface provides several subcommands for managing processes:
Stop - Stop the process manager or a specific service:
# Stop the supervisor and every managed service
$ sysg stop
# Stop a specific service
$ sysg stop --service myapp
Restart - Restart the process manager:
# Restart all services managed by the supervisor
$ sysg restart
# Restart a specific service
$ sysg restart -s myapp
# Restart with a different configuration
$ sysg restart --config new-config.yaml
Status - Check the status of running services:
# Show status of all services (uses default systemg.yaml)
$ sysg status
# Show status with a specific configuration file
$ sysg status --config myapp.yaml
# Show status of a specific service
$ sysg status --service webserver
# Show all services including orphaned state
$ sysg status --all
Inspect - Inspect a service or cron unit in detail:
# Inspect a specific service or cron unit by name or hash
$ sysg inspect myservice
# Show metrics in JSON format
$ sysg inspect myservice --json
# Display only the most recent data (last 2 minutes)
$ sysg inspect myservice --window 2m
# Render output without ANSI coloring
$ sysg inspect myservice --no-color
Logs - View logs for a specific service:
# View the last 50 lines of stdout logs (default)
$ sysg logs
# View logs for a specific service
$ sysg logs api-service
# View a custom number of log lines
$ sysg logs database --lines 100
# View specific log type (stdout, stderr, or supervisor)
$ sysg logs myservice --kind stderr
Log Level - Override logging verbosity:
# Override logging verbosity for the current run (works with every subcommand; names or 0-5)
$ sysg start --log-level debug
$ sysg start --log-level 4
| Feature | systemg | systemd | Supervisor | Docker Compose |
|---|---|---|---|---|
| Focus | Program Composition | System Management | Process Supervision | Container Orchestration |
| Abstractions | Systems of Programs | Individual Units | Individual Processes | Container Services |
| Configuration | Declarative YAML | Unit Files | INI Files | YAML |
| Dependencies | Topological with Health | Complex Chains | Manual Priority | Service Links |
| Deployment | Built-in Rolling | External Tools | Manual | Recreate/Rolling |
| Runtime Deps | None | DBus, Journal | Python | Docker Daemon |
| OS Integration | Optional | Required (PID 1) | None | Container Runtime |
To run the test suite:
# Run all tests
$ cargo test
# Run specific test
$ cargo test test_service_lifecycle
To build systemg from source:
# Clone the repository
$ git clone https://github.com/ra0x3/systemg.git
$ cd systemg
# Build the project
$ cargo build --release
# The binary will be available at target/release/sysg
Contributions to systemg are welcome! Please see the CONTRIBUTING.md file for guidelines.