fix(daemon): prevent zombie state after database file replacement (#1213)

fix(daemon): prevent zombie state after database file replacement

Adds checkFreshness() to health check paths (GetMetadata, GetConfig, GetAllConfig) and refactors reconnect() to validate new connection before closing old.

PR-URL: https://github.com/steveyegge/beads/pull/1213
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Roland Tritsch
2026-01-22 06:46:59 +00:00
committed by GitHub
parent 78e1d6f229
commit 5264d7aa60
8 changed files with 588 additions and 23 deletions

View File

@@ -13,13 +13,13 @@ import (
"github.com/steveyegge/beads/internal/lockfile"
)
// rpcDebugEnabled returns true if BD_RPC_DEBUG environment variable is set
// rpcDebugEnabled returns true if BD_DEBUG_RPC environment variable is set
func rpcDebugEnabled() bool {
val := os.Getenv("BD_RPC_DEBUG")
val := os.Getenv("BD_DEBUG_RPC")
return val == "1" || val == "true"
}
// rpcDebugLog logs to stderr if BD_RPC_DEBUG is enabled
// rpcDebugLog logs to stderr if BD_DEBUG_RPC is enabled
func rpcDebugLog(format string, args ...interface{}) {
if rpcDebugEnabled() {
fmt.Fprintf(os.Stderr, "[RPC DEBUG] "+format+"\n", args...)