Skip to main content

Architecture Overview

Runix is a single-binary process manager built in Go. It uses a supervisor pattern to manage long-running processes, communicating through a lightweight daemon layer when running in background mode.

System Architecture​

Dual-Mode Execution​

Every CLI command follows the same dual-mode pattern:

  • Daemon mode — When the daemon is running, CLI commands send HTTP requests to ~/.runix/runix.sock. The daemon holds the single Supervisor instance and all process state.
  • Direct mode — When the daemon is not running, commands create a temporary Supervisor instance and execute locally. State is loaded from disk.

Key Design Principles​

PrincipleImplementation
Single binaryNo CGO, fully static compilation. CGO_ENABLED=0 everywhere.
Lock-free stateProcess state uses atomic.Value + CompareAndSwap — no mutexes on the hot path.
Process group isolationSetpgid: true + Kill(-pid, signal) ensures clean termination of entire process groups.
Dependency rootpkg/types is the shared kernel — imported by everything, imports nothing from internal/.
Explicit initializationNo init() functions. All setup via New*() constructors.
Structured loggingzerolog throughout. Errors are returned, never logged-and-forgotten.

Module Map​

ModuleLocationResponsibility
CLIcmd/runix/28+ cobra commands, thin wrappers around internal packages
Supervisorinternal/supervisor/Core engine — process lifecycle, state machine, restart/backoff
Daemoninternal/daemon/HTTP-over-Unix-socket IPC, fork/exec lifecycle, PID management
Runtimeinternal/runtime/Adapters for Go, Python, Node.js, Bun, Deno, Ruby, PHP
Configinternal/config/Config loading via viper, defaults, extends, hot-reload diffing
Hooksinternal/hooks/Lifecycle hook execution (sh -c), hook chains
Metricsinternal/metrics//proc-based metrics collector, Prometheus exposition format
Schedulerinternal/scheduler/Cron job scheduling via robfig/cron with seconds support
Watcherinternal/watcher/fsnotify file watching with debounce and ignore patterns
Healthcheckinternal/healthcheck/HTTP, TCP, and command health checks with retry logic
Eventsinternal/events/Pub/sub event bus with persistent JSON log store
Secretsinternal/secrets/Secret resolution from env vars, files, and (planned) Vault
Authinternal/auth/Authentication — basic, token, and local-only modes
cgroupsinternal/cgroups/Linux cgroups v2 resource limits (CPU quota, memory cap)
Log Rotationinternal/logrot/Size-based log rotation with count and age pruning
Updaterinternal/updater/Self-update via GitHub Releases API with SHA256 verification
MCPinternal/mcp/Model Context Protocol server (stdio + HTTP transports)
Web UIinternal/web/Chi HTTP server + WebSocket for live dashboard
TUIinternal/tui/BubbleTea terminal UI with process table, log view, help
SDKsdk/Embeddable Go SDK for in-process process management
Versioninternal/version/Version and BuildTime injected via ldflags
Typespkg/types/Shared types — ProcessConfig, State, hooks, health checks, etc.

Data Flow​

What's Next​