Implement daemon auto-start with comprehensive improvements (bd-124)
- Auto-starts daemon on first bd command (unless --no-daemon or BEADS_AUTO_START_DAEMON=false) - Exponential backoff on failures: 5s, 10s, 20s, 40s, 80s, 120s (max) - Lockfile prevents race conditions when multiple commands start daemon simultaneously - Stdio redirected to /dev/null to prevent daemon output in foreground - Uses os.Executable() for security (prevents PATH hijacking) - Socket readiness verified with actual connection test - Accepts multiple falsy values: false, 0, no, off (case-insensitive) - Working directory set to database directory for local daemon context - Comprehensive test coverage including backoff math and concurrent starts Fixes: - Closes bd-1 (won't fix - compaction keeps DBs small) - Closes bd-124 (daemon auto-start implemented) Documentation updated in README.md and AGENTS.md Amp-Thread-ID: https://ampcode.com/threads/T-b10fe866-ab85-417f-9c4c-5d1f044c5796 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -518,6 +518,13 @@ bd create "Fix navbar bug" # Uses ~/myproject/.beads/myapp.db
|
||||
bd --db ~/otherproject/.beads/other.db list
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- `BEADS_DB` - Override database path
|
||||
- `BEADS_AUTO_START_DAEMON` - Enable/disable automatic daemon start (default: `true`). Set to `false` or `0` to disable.
|
||||
- `BD_ACTOR` - Set actor name for change tracking (defaults to `$USER`)
|
||||
- `BD_DEBUG` - Enable debug logging for troubleshooting
|
||||
|
||||
## Dependency Model
|
||||
|
||||
Beads has four types of dependencies:
|
||||
@@ -899,6 +906,8 @@ bd daemon --status
|
||||
bd daemon --stop
|
||||
```
|
||||
|
||||
**Note:** As of v0.9.11, the daemon **automatically starts** when you run any `bd` command if it's not already running. You typically don't need to manually start it. The auto-start feature can be disabled by setting `BEADS_AUTO_START_DAEMON=false` or using the `--no-daemon` flag.
|
||||
|
||||
The daemon will:
|
||||
- Poll for changes at configurable intervals (default: 5 minutes)
|
||||
- Export pending database changes to JSONL
|
||||
|
||||
Reference in New Issue
Block a user