Warn when a usr1/usr2 restart leaves a config change unapplied - #42
Open
facundofarias wants to merge 1 commit into
Open
facundofarias wants to merge 1 commit into
facundofarias wants to merge 1 commit into
Conversation
Supervisor#restart reloads the configuration before restarting anything, so `procodile restart` does pick up changes to the Procfile, Procfile.options and Procfile.local -- Config#reload clears @options, @local_options and @environment_variables. Whether a given process *sees* those changes depends entirely on its restart_mode. start-term and term-start spawn a replacement, which is given the freshly computed environment. usr1 and usr2 signal the running process instead: ::Process.kill(@process.restart_mode.upcase, @pid) Nothing is re-spawned, and the environment is only ever applied at Process.spawn, so a usr1 process keeps the environment it was born with indefinitely. Procodile reports the restart as successful either way, and there is no indication that the change did not land. Diagnosing this from the outside is genuinely hard: the config on disk is correct, `status` looks healthy, and only the application's behaviour disagrees. Record the environment and command each instance was actually spawned with, and after signalling a usr1/usr2 process, log a warning if either has since changed. Instances that this supervisor never spawned record nothing and are skipped, so there are no false warnings after a supervisor restart. The check only fires when something genuinely changed, so routine restarts are unaffected. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P89F451YDRDBj5br14i3GD
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.
Problem
Supervisor#restartreloads the configuration before restarting anything, andConfig#reloadclears@options,@local_optionsand@environment_variables— soprocodile restartgenuinely does pick up Procfile/Procfile.options/Procfile.local changes.Whether a given process sees them depends entirely on
restart_mode:start-term,term-startusr1,usr2::Process.kill(mode, @pid)usr1/usr2signal the running process rather than replacing it. The environment is only ever applied atProcess.spawn, so such a process keeps the environment it was born with indefinitely — while Procodile reports the restart as successful.This is genuinely hard to diagnose from outside: the config on disk is correct,
statuslooks healthy, and only the application's behaviour disagrees. We lost time to exactly this — an environment variable added toProcfile.local,procodile restartrun, and the value never reached the process.Change
Record the environment and command each instance was actually spawned with. After signalling a
usr1/usr2process, log a warning if either has since changed:Notes
Specs in
spec/specs/instance_spec.rbcover unchanged, environment-changed, variable-added, command-changed, both-changed, and never-spawned. Full suite green (40 examples).