feat(daemon): add --foreground flag for systemd/supervisord integration
Adds --foreground flag to 'bd daemon --start' that runs the daemon in foreground instead of forking to background. This enables management by process supervisors like systemd, supervisord, or similar tools. Usage: bd daemon --start --foreground Closes #438 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -275,15 +275,16 @@ func stopDaemon(pidFile string) {
|
||||
fmt.Println("Daemon killed")
|
||||
}
|
||||
|
||||
// startDaemon starts the daemon in background
|
||||
func startDaemon(interval time.Duration, autoCommit, autoPush, localMode bool, logFile, pidFile string) {
|
||||
// startDaemon starts the daemon (in foreground if requested, otherwise background)
|
||||
func startDaemon(interval time.Duration, autoCommit, autoPush, localMode, foreground bool, logFile, pidFile string) {
|
||||
logPath, err := getLogFilePath(logFile)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if os.Getenv("BD_DAEMON_FOREGROUND") == "1" {
|
||||
// Run in foreground if --foreground flag set or if we're the forked child process
|
||||
if foreground || os.Getenv("BD_DAEMON_FOREGROUND") == "1" {
|
||||
runDaemonLoop(interval, autoCommit, autoPush, localMode, logPath, pidFile)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user