Server
Server Overview
How the NomadFlowCode server starts and runs.
The NomadFlowCode server is an Axum HTTP server that provides the API for managing repos, features, and terminal access.
Launch modes
| Command | Behavior |
|---|---|
nomadflow | Starts the server in the background, then launches the TUI wizard. Server stops gracefully when TUI exits. |
nomadflow serve | Server-only mode in foreground with full tracing/logging. Ideal for headless or Docker deployments. Handles Ctrl+C and SIGTERM gracefully. |
nomadflow start | Starts the server as a background daemon. PID file: ~/.nomadflowcode/nomadflow.pid, logs: ~/.nomadflowcode/nomadflow.log. |
nomadflow stop | Stops the background daemon via SIGTERM (graceful shutdown). |
Startup sequence
When the server starts, it:
- Loads configuration from
~/.nomadflowcode/config.toml(falls back to defaults). - Creates directories —
~/.nomadflowcode/repos/and~/.nomadflowcode/worktrees/. - Ensures a tmux session exists (creates one if needed).
- Starts ttyd — spawns a ttyd subprocess attached to the tmux session on the configured port (default 7681).
- Binds the HTTP server on the configured host and port (default
0.0.0.0:8080).
Graceful shutdown
The server supports graceful shutdown via CancellationToken. When a shutdown signal is received (Ctrl+C, SIGTERM, or programmatic cancellation):
- The HTTP server stops accepting new connections.
- In-flight requests are allowed to complete.
- The ttyd subprocess is stopped — no orphan processes left behind.
- The server exits cleanly.
This applies to all modes: serve (foreground), start/stop (daemon), and the default TUI mode.
Routes
GET /health— health check (no auth)POST /api/*— repo and feature management (Bearer token auth)GET /terminal/ws— WebSocket proxy to ttyd (token query param auth)
See API Reference for full details.
Deployment
Bare metal (foreground)
nomadflow serveSet RUST_LOG=nomadflow_server=debug for verbose logging.
Bare metal (daemon)
# Start
nomadflow start
# Check status
nomadflow --status
# Stop
nomadflow stopSystemd
[Unit]
Description=NomadFlowCode Server
After=network.target
[Service]
ExecStart=/usr/local/bin/nomadflow serve
Restart=on-failure
Environment=RUST_LOG=nomadflow_server=info
[Install]
WantedBy=multi-user.targetDocker
Ensure the container has tmux and ttyd installed, and that the tmux session can be created inside the container.