fix: single-instance daemon lock — refuse second hermes-node run - #123
Merged
Merged
Conversation
Multiple daemon instances were stacking up on workmac when hermes-node run was invoked from several terminal sessions; each forked a new daemon and they fought over the same pairing token, so no node could stay connected. Add a single-instance guard backed by a daemon.lock file next to config.toml: - runRun (the daemon itself) refuses to start if a live PID holds the lock - runDetach (the CLI wrapper) refuses before forking, so the error lands on the terminal instead of inside daemon.log - stale locks (dead PID) are reclaimed automatically, so a crash doesn't wedge future starts; the lock is removed on a clean exit Tests: live-lock refusal at both layers, lock acquisition + cleanup on a fresh start, and stale-lock takeover. Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
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
Multiple
hermes-nodedaemons were stacking up on workmac whenhermes-node runwas invoked from several terminal sessions — each forked a new daemon and they fought over the same pairing token, so no node could stay connected.Adds a single-instance guard backed by a
daemon.lockfile next toconfig.toml:run(the daemon itself) refuses to start if a live PID holds the lock →daemon already running (PID N) — run 'hermes-node stop' firstrunDetach(the CLI wrapper) refuses before forking, so the error lands on the terminal instead of insidedaemon.logTest Plan
go test ./...passes;go vet+gofmtcleanNotes
TestReconnect_RecoversAfterServerRestartininternal/wireis a pre-existing flake (fails intermittently, unrelated to this change; passes in isolation and in full-suite runs)