- Pre-flight checks: Kills existing Rhino processes, validates autosave is disabled
- Configuration: Loads config from environment, validates settings
- Manager initialization: Creates Rhino manager with health monitoring config
- Rhino launch: Starts Rhino as detached subprocess with
-runscriptflag - Health check: Waits 20s then polls TCP endpoint until healthy (30s timeout)
- Monitoring: Starts background health checks (every 30s) and process monitoring
- HTTP server: Starts REST API with request queue and proxy to Python server
The Manager handles Rhino's complete lifecycle:
Startup:
- Detaches Rhino process (new process group) to prevent zombies
- Redirects stdout/stderr to
/tmp/rhino-output.log - Passes server script via
-runscriptwith-nosplashflag - Opens
empty.3dmto prevent "open file" dialog - Handles first-run autosave toggle (auto-restarts if needed)
Health Monitoring:
- HTTP health checks: Every 30s, hits
/healthzon TCP port 17890 - Process checks: Every 30s, verifies Rhino + RhinoMonitor PIDs exist
- Auto-restart: On health failure, attempts graceful restart (if enabled)
- Uses
syscall.Kill(pid, 0)to verify process existence without sending signals
Child Process Tracking:
- Discovers Rhinoceros (main) and RhinoMonitor (helper) PIDs via
ps -axo - Monitors both processes to detect crashes/zombies
- Waits 5s after launch for child processes to spawn
Shutdown:
- Graceful: Sends SIGINT, waits for clean exit (10s timeout)
- Force: Sends SIGKILL if graceful fails or timeout exceeded
- Stops health/process monitoring tickers and closes channels
rhino-cli/
├── cmd/rhino/ # CLI commands
│ ├── main.go
│ ├── server.go # Server command
│ ├── exec.go # Exec command
│ ├── eval.go # Eval command
│ └── doctor.go # Doctor command
├── pkg/
│ ├── config/ # Configuration
│ ├── embedded/ # Embedded Python scripts
│ ├── proxy/ # HTTP client to Python server
│ ├── queue/ # Request queue
│ ├── rhino/ # Rhino process manager
│ ├── server/ # HTTP server
│ └── log/ # Logging utilities
├── scripts/ # Python scripts
│ └── rhino-server.py # Embedded Python server
├── docs/ # Documentation
└── ainotes/ # Development notes