Skip to content

fix(cli): restart the daemon on update, so a new build actually takes effect - #173

Merged
ralyodio merged 1 commit into
masterfrom
fix/upgrade-holders-and-daemon
Aug 30, 2026
Merged

fix(cli): restart the daemon on update, so a new build actually takes effect#173
ralyodio merged 1 commit into
masterfrom
fix/upgrade-holders-and-daemon

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

The gap

threatcrush update already did the hard parts — installs @latest (defeating both the range-bound update -g and pnpm's global lockfile pin), updates every package manager holding a copy, and warns when PATH still resolves somewhere older.

It never touched the daemon. Updating the CLI replaces files on disk and nothing else, so a daemon already running keeps executing the bundle it was spawned from. On one host that was 0.11.3 out of a pnpm store path for a version no longer installed at all, while the CLI beside it reported 0.11.6 and every update printed ✓ ThreatCrush updated successfully!. Nothing in the output hinted the thing actually serving traffic hadn't moved.

Change

  • update and install.sh now bring the daemon onto the new build and say so.
  • Not unconditional. A systemd-managed daemon must go through systemd — threatcrush restart there stops the supervised copy and starts an unsupervised one systemd knows nothing about. Detected by comparing the unit's MainPID against the running daemon; we hand over sudo systemctl restart threatcrushd instead.
  • After restart, the daemon's reported version is compared to the CLI's, so a daemon that stayed behind is stated rather than assumed.
  • Notes that an open monitor --tui holds the old code until relaunched — it loads at launch, which is its own way of looking like a failed upgrade.

Verification

Tested against a genuinely stale daemon, not a mock. The dev box had CLI 0.11.7 beside a daemon on 0.11.4:

✓ ThreatCrush updated successfully!
Restarting threatcrushd onto the new build...
✓ threatcrushd stopped.
✓ threatcrushd started (pid 692346)
If a `threatcrush monitor --tui` is open, quit and relaunch it.

threatcrush status then reported Version: 0.11.7.

The systemd branch was checked against the live supervised daemon on the other host: MainPID=1150300 equals its pidfile, so detection returns managed and it hands over the systemctl command rather than restarting.

  • pnpm test — 73 passed (7 files), up from 62.
  • pnpm build clean; sh -n install.sh POSIX-valid.

🤖 Generated with Claude Code

https://claude.ai/code/session_018NXz7vRz6C7vaGSwMgWZfD

… effect

Updating the CLI replaced files on disk and nothing else. A daemon that was
already running kept executing the bundle it was spawned from — on one host,
0.11.3 out of a pnpm store path for a version that was no longer installed at
all — while the CLI beside it reported 0.11.6 and every `update` printed
"✓ ThreatCrush updated successfully!". Nothing in the output hinted that the
thing actually serving traffic had not moved.

`update` and install.sh now bring the daemon onto the new build, and say so.

Restarting it is not unconditional: a systemd-managed daemon must go through
systemd, because `threatcrush restart` there stops the supervised copy and
starts an unsupervised one in its place. We detect that by comparing the unit's
MainPID against the running daemon and hand over `systemctl restart` instead.

After a restart the daemon's reported version is compared against the CLI's, so
a daemon that somehow stayed behind is now stated rather than assumed. Also note
that an open `monitor --tui` holds the old code until it is relaunched — it
loads at launch, which is its own way of looking like a failed upgrade.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018NXz7vRz6C7vaGSwMgWZfD
@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

12 finding(s)

HIGH/CRITICAL: 1 | MEDIUM: 6 | LOW: 5

Severity Rule Location
HIGH secret-aws-access-key prd/0003-detect-hardcoded-secrets-before-they-are-committed-or-served.md:126
MEDIUM js-open-redirect apps/web/src/app/auth/login/page.tsx:50
MEDIUM js-unescaped-html-sink apps/web/src/app/hire/page.tsx:96
MEDIUM js-unescaped-html-sink apps/web/src/app/hire/page.tsx:100
MEDIUM js-open-redirect apps/web/src/components/funding/FundingClient.tsx:97
MEDIUM js-unescaped-html-sink apps/web/src/components/GuideReader.tsx:265
MEDIUM js-uninitialized-buffer packages/scan/src/node-rules.ts:456
LOW secret-generic-credential PRD.md:269
LOW tls-verification-disabled prd/0004-find-dangerous-code-patterns-without-pretending-to-be-a-compiler.md:121
LOW tls-verification-disabled prd/0004-find-dangerous-code-patterns-without-pretending-to-be-a-compiler.md:122
LOW sh-remote-script-execution scripts/smoke-test.sh:47
LOW secret-aws-access-key scripts/smoke-test.sh:112

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio
ralyodio merged commit b457e05 into master Aug 30, 2026
11 checks passed
@ralyodio
ralyodio deleted the fix/upgrade-holders-and-daemon branch August 30, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant