engage: add -r flag to reload config of a running squadron#103
Open
mlund01 wants to merge 1 commit into
Open
Conversation
A second `squadron engage` against a config dir that already has a running instance now errors out with a hint, instead of attempting a fork that would have failed later in daemon.Fork's IsRunning check. Passing `-r` / `--reload` to a second `engage` signals the running daemon over SIGHUP to re-read and validate its config. The reload runs through the same wsbridge.Client.ReloadConfig path the command center uses, so it inherits the validate-then-atomic-swap semantics: a broken config is rejected and the running daemon keeps its previous config. If `-r` is passed when nothing is running, the flag is noted and ignored and engage starts squadron normally. Includes tests for daemon.Reload covering: missing PID file, malformed PID file, stale PID, and actual SIGHUP delivery to a live process.
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
squadron engageagainst a config dir that already has a running instance now errors out with a clear hint, instead of forking and dying later indaemon.Fork'sIsRunningcheck.--reload/-rflag: signals the running daemon (SIGHUP) to re-read and validate its config. The reload goes through the samewsbridge.Client.ReloadConfigpath the command center uses, so it inherits the validate-then-atomic-swap semantics — a broken config is rejected and the running daemon keeps its previous config.-rwith no running daemon is a no-op: prints a message and proceeds with normal startup.Behavior matrix
-r?Squadron is not running — ignoring -r and starting it now., then normal startupError: squadron is already running (PID N).+ suggestion to use-rordisengage, exits 1Config reloaded successfully.; failure → error printed, daemon keeps previous config)What the user sees on
-rSuccess:
Failure (validation error in new HCL):
Implementation notes
daemon.Reload(configPath) (int, error)sends SIGHUP to the PID recorded inengage.pid.client.ReloadConfig()(existing function — same one the command center'sTypeReloadConfighandler calls). On validation failure the handler writesSignalFailedto the ready file; on success the existingOnConfigLoadedcallback writesSignalReady.engage -rclears the ready file, sends SIGHUP viadaemon.Reload, thenWaitReadys for the daemon's result with a 30s timeout.Test plan
go build ./...go test ./internal/daemon/ ./cmd/squadron engage→ see already-running errorsquadron engage -r→ see reload succeedsquadron engage -r→ see error + confirmation old config still activesquadron engage -rwith nothing running → see "ignoring -r" message and normal startup