Daemon Configuration¶
The Brat daemon (bratd) provides the HTTP API for the web UI and multi-session coordination.
Overview¶
The daemon:
- Serves the HTTP API for the web dashboard
- Manages multiple concurrent sessions
- Supervises harness roles
- Auto-starts and auto-stops based on activity
Starting the Daemon¶
Auto-Start (Default)¶
Most commands auto-start the daemon when needed:
Disable auto-start:
Manual Start¶
# Start in background
brat daemon start
# Start with custom port
brat daemon start --port 8080
# Start with longer idle timeout
brat daemon start --idle-timeout 3600
# Start in foreground (for debugging)
brat daemon start --foreground
Stopping the Daemon¶
Or set an idle timeout - the daemon stops automatically after inactivity.
Checking Status¶
Restarting¶
Configuration¶
In Config File¶
Environment Variables¶
Options¶
| Option | Default | Description |
|---|---|---|
port | 3000 | HTTP API port |
idle_timeout_secs | 900 | Shutdown after idle (0 = never) |
Idle Timeout¶
The daemon shuts down after idle_timeout_secs of no activity:
- API requests reset the timer
- Active sessions prevent shutdown
- Set to
0to disable timeout
Standalone Binary¶
The daemon is also available as a standalone binary:
Logs¶
View daemon logs:
Log location: ~/.brat/logs/bratd.log
API Endpoints¶
The daemon serves these endpoints:
| Endpoint | Method | Description |
|---|---|---|
/api/status | GET | Harness status |
/api/convoys | GET, POST | Convoy operations |
/api/convoys/:id | GET | Convoy details |
/api/tasks | GET, POST | Task operations |
/api/tasks/:id | GET, PUT | Task details |
/api/sessions | GET | Session list |
/api/sessions/:id | GET, DELETE | Session details |
/api/mayor | POST | Mayor commands |
WebSocket¶
The daemon provides real-time updates via WebSocket:
Events:
- Task status changes
- Session heartbeats
- Convoy updates
Multi-Repository¶
One daemon can manage multiple repositories:
Commands target the current directory by default. Use --repo to specify:
Troubleshooting¶
Daemon Won't Start¶
Check if port is in use:
Use a different port:
Can't Connect¶
Verify daemon is running:
Check the logs:
Daemon Keeps Stopping¶
Increase idle timeout:
Or disable:
Running Without Daemon¶
All CLI commands work without the daemon:
The daemon is optional for correctness - it provides UX benefits but isn't required.
Use --no-daemon for:
- CI/CD pipelines
- Scripts
- Minimal resource usage