feat(daemon): add auto_pull config parameter for periodic remote sync
Add --auto-pull flag to control whether the daemon periodically pulls from remote to check for updates from other clones. Configuration precedence: 1. --auto-pull CLI flag (highest) 2. BEADS_AUTO_PULL environment variable 3. daemon.auto_pull in database config 4. Default: true when sync.branch is configured When auto_pull is enabled, the daemon creates a remoteSyncTicker that periodically calls doAutoImport() to pull remote changes. When disabled, users must manually run 'git pull' to sync remote changes. Changes: - cmd/bd/daemon.go: Add --auto-pull flag and config reading logic - cmd/bd/daemon_event_loop.go: Gate remoteSyncTicker on autoPull parameter - cmd/bd/daemon_lifecycle.go: Add auto-pull to status output and spawn args - internal/rpc/protocol.go: Add AutoPull field to StatusResponse - internal/rpc/server_core.go: Add autoPull to Server struct and SetConfig - internal/rpc/server_routing_validation_diagnostics.go: Include in status - Tests updated to pass autoPull parameter Closes #TBD
This commit is contained in:
@@ -102,6 +102,7 @@ func showDaemonStatus(pidFile string) {
|
||||
fmt.Printf(" Sync Interval: %s\n", rpcStatus.SyncInterval)
|
||||
fmt.Printf(" Auto-Commit: %v\n", rpcStatus.AutoCommit)
|
||||
fmt.Printf(" Auto-Push: %v\n", rpcStatus.AutoPush)
|
||||
fmt.Printf(" Auto-Pull: %v\n", rpcStatus.AutoPull)
|
||||
if rpcStatus.LocalMode {
|
||||
fmt.Printf(" Local Mode: %v (no git sync)\n", rpcStatus.LocalMode)
|
||||
}
|
||||
@@ -359,7 +360,7 @@ func stopAllDaemons() {
|
||||
}
|
||||
|
||||
// startDaemon starts the daemon (in foreground if requested, otherwise background)
|
||||
func startDaemon(interval time.Duration, autoCommit, autoPush, localMode, foreground bool, logFile, pidFile string) {
|
||||
func startDaemon(interval time.Duration, autoCommit, autoPush, autoPull, localMode, foreground bool, logFile, pidFile string) {
|
||||
logPath, err := getLogFilePath(logFile)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
@@ -368,7 +369,7 @@ func startDaemon(interval time.Duration, autoCommit, autoPush, localMode, foregr
|
||||
|
||||
// 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)
|
||||
runDaemonLoop(interval, autoCommit, autoPush, autoPull, localMode, logPath, pidFile)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -387,6 +388,9 @@ func startDaemon(interval time.Duration, autoCommit, autoPush, localMode, foregr
|
||||
if autoPush {
|
||||
args = append(args, "--auto-push")
|
||||
}
|
||||
if autoPull {
|
||||
args = append(args, "--auto-pull")
|
||||
}
|
||||
if localMode {
|
||||
args = append(args, "--local")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user