Repository navigation
Decide if the daemon runs from a lock file, not from the PID - #456
Open
alex-clickhouse wants to merge 1 commit into
Open
alex-clickhouse wants to merge 1 commit into
alex-clickhouse wants to merge 1 commit into
Conversation
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.
On a systemd install,
nerve startfailed with "Nerve is already running" after a reboot. systemd restarted it every 10 seconds for two days.Cause:
finallyinstartremovesnerve.pid, so the file stays after each stop.os.kill(pid, 0)raisedPermissionError, and the check counts that as "running".A reused PID can also belong to a process of the same user. Then
nerve stopsends SIGTERM to that process.Changes
nerve/pidfile.py): the daemon holds an exclusiveflockon~/.nerve/nerve.lockwhile it runs. The kernel releases the lock when the process stops for any reason, including SIGKILL and a reboot. The daemon is running only if the lock is held. The PID innerve.pidis only for display and signals.start --foregroundtakes the lock before it starts the server. If two starts occur at the same time, only one gets the lock.nerve/backup.py) uses the same check.nerve.lockdoes not exist, the check uses the PID as before. Thusnerve upgrade && nerve restartstill stops the old daemon.nerve.lockis never deleted. Status checks do not delete a stalenerve.pid, because it has no effect.Tests
acquirefails while the lock is held and does not change the PID file.The full suite passes locally. I also ran
nerve statusfor each of these cases: a reused PID, a held lock, and a killed lock holder. I did not run a full daemon start and stop under systemd.🤖 Generated with Claude Code