Gosuper is a lightweight, high-performance process supervisor and daemon written in Go. Inspired by tools like supervisord and PM2, Gosuper allows you to manage, monitor, and control background services using YAML configuration files over a Unix Domain Socket HTTP API.
- Architecture & Design
- Installation & Building
- Configuration (
gosuper.yaml) - CLI Command Usage
- Unix Socket HTTP API
- Project Status & Roadmap
- Development & Testing
Gosuper is structured into decoupled modules:
gosuper/
├── cmd/ # Cobra CLI command definitions (daemon, service, supervisor)
├── internal/
│ ├── client/ # Go HTTP client communicating over Unix Domain Socket
│ ├── config/ # YAML configuration loader & types
│ ├── core/ # Process management engine, Service & Supervisor state machines
│ ├── logging/ # Multi-writer logging setup (stdout + log files)
│ ├── server/ # HTTP Daemon server listening on Unix socket (tmp/gosuper.sock)
│ └── types/ # Shared API request/response types
├── gosuper.yaml # Default configuration file
└── main.go # Application entry point
- Go: 1.22 or higher
# Clone repository
git clone https://github.com/pak-app/gosuper.git
cd gosuper
# Build binary
go build -o gosuper main.goGosuper uses YAML configuration files to define supervisor settings and managed service specifications.
# gosuper.yaml
# Global supervisor configuration
supervisor:
name: 'dev-supervisor'
log_dir: './log/gosuper'
restart_delay: 2s
stop_timeout: 5s
env:
APP_ENV: development
# Defined services managed by the supervisor
services:
dummy_worker:
command: ["./dummy.sh"]
dir: "./tmp"
autostart: true
autorestart: true
restart_limit: 5
restart_window: 30s
stdout: "worker.out.log"
stderr: "worker.err.log"
env:
DEBUG: "true"
dummy_api:
command: ["./api_server"]
dir: "./tmp"
autostart: true
autorestart: true
stdout: "api.out.log"
stderr: "api.err.log"The gosuper CLI provides commands to manage the daemon and running services.
- Start Daemon in Background:
./gosuper daemon start
- Run Daemon in Foreground (Serve):
./gosuper daemon serve
- Check Daemon Health:
./gosuper daemon status
- Stop Daemon:
./gosuper daemon stop
- Start Services (from config):
./gosuper service start --config gosuper.yaml
- Check Service & Supervisor Status:
./gosuper service status --supervisor-name dev-supervisor
- Stop Services:
./gosuper service stop --supervisor-name dev-supervisor
The daemon listens on tmp/gosuper.sock by default and exposes RESTful HTTP endpoints:
| Endpoint | Method | Description |
|---|---|---|
/daemon/status |
GET |
Get daemon health status and active supervisor count |
/daemon/stop |
POST |
Gracefully shut down the HTTP server and remove socket |
/service/start |
POST |
Load configuration payload and start supervisor services |
/service/status |
GET |
Get status of all supervisors or filter by ?supervisor_name= |
/service/stop |
POST |
Stop all services under a supervisor specified by ?supervisor_name= |
- Concurrent process execution engine (
internal/core) - Process state tracking (
Starting,Running,Stopping,Stopped,Failed) - Uptime calculation & PID tracking
- Unix Domain Socket HTTP server & Client library
- YAML Configuration loading (
internal/config) - Cobra CLI interface (
cmd/) - Multi-writer logging (
internal/logging)
- Auto-restart on Crash: Implement automatic retry backoff based on
restart_limit&restart_window. - Log File Redirection: Connect service
stdout/stderrconfigs to file loggers instead of inheriting daemon stdout. - Environment Variable Merging: Inject
supervisor.envandservice.envinto child process execution environments. - Single Service Control: Support starting/stopping individual services within a supervisor group.
- Configuration Schema Validation: Add validation logic in
internal/config/validation.go. - Log Streaming API: Implement
/logendpoint for real-time log tailing.
Run unit tests across all packages:
go test ./...