fix(daemon): detect and restart stale daemons after binary upgrade#613
Merged
fix(daemon): detect and restart stale daemons after binary upgrade#613
Conversation
After cargo install, old daemon processes kept running from the previous binary. Auto-start saw the daemon alive via ping and returned immediately, never comparing binaries. Now the daemon records its binary path + mtime at startup in ~/.kild/daemon.bin. On auto-start, if the running daemon's recorded mtime differs from the current binary on disk, it is gracefully restarted. - kild daemon status warns when the daemon is stale - kild daemon restart added as a convenience command (stop + start) - ensure_daemon_running auto-restarts stale daemons transparently Closes #608
- Fix autostart logic: stale restart now bypasses auto_start guard, preventing Disabled error after stopping a stale daemon - Fix mtime fallback: return false (not stale) when mtime is unreadable, preventing false-positive restart loops - Fix bin_path derivation: use KildPaths-based bin_file_path() in both daemon and client for consistent path resolution - Add proper error logging to kild-core read_bin_file (match daemon version) - Extract spawn_daemon_background() helper to deduplicate CLI start/restart
…ents Silent failure fixes: - Log find_sibling_binary error in is_daemon_stale instead of swallowing - Return Option<u32> from spawn_daemon_background to avoid printing PID 0 - Log mtime read failure in write_bin_file instead of silent fallback - Wait for socket removal (not just PID file) in stop_stale_daemon - Add error! log on restart stop timeout path - Make handle_daemon_start PID read failure soft (was hard error) - Log mtime parse failures in both read_bin_file implementations Simplification: - Replace needs_spawn flag with early return spawn_daemon() in ensure_daemon_running for clearer control flow Comment fixes: - Update run_server docstring to include bin file write step - Match bin_file_path doc to daemon version with path literal - Add actionable hint when stale daemon stop fails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
~/.kild/daemon.binensure_daemon_runningdetects stale daemons (binary updated since startup) and auto-restarts themkild daemon statuswarns when the running daemon is stalekild daemon restartcommand (stop + start)Test plan
cargo install --path crates/kild-daemon)kild daemon statusshows stale warning after upgradekild daemon restartstops old daemon and starts new onekild create --daemonauto-restarts stale daemon transparentlydaemon.bincargo test -p kild-paths -p kild-daemon -p kild-core— all passCloses #608