Skip to content

fix(cli): stop install-service writing a unit that dies on upgrade and reboot - #172

Merged
ralyodio merged 1 commit into
masterfrom
fix/install-service-stable-path
Aug 30, 2026
Merged

fix(cli): stop install-service writing a unit that dies on upgrade and reboot#172
ralyodio merged 1 commit into
masterfrom
fix/install-service-stable-path

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

What

Two independent defects left threatcrushd.service permanently unstartable on a real host (bittorrented-droplet), found at 6315 failed starts against a path last valid at 0.2.1.

1. ExecStart pinned to a version-stamped path

resolveBinPath() returned process.argv[1], which under a pnpm global install is …/.pnpm/@profullstack+threatcrush@X.Y.Z/node_modules/…. The next upgrade moves that directory, ExecStart points at nothing, and Restart=on-failure turns it into an endless loop.

Now rewritten to the stable symlink pnpm maintains at the store root, and only when that symlink actually exists — npm's global layout is already version-free and is left untouched.

2. A tmpfs path under ReadWritePaths

The unit listed /var/run/threatcrush. /var/run is a symlink to the /run tmpfs, so the directory ensureSystemDirs() created at install time was gone after the next reboot — and a missing ReadWritePaths entry fails the unit 226/NAMESPACE on every start.

Replaced with RuntimeDirectory=threatcrush, which systemd creates per start and cleans up; ensureSystemDirs() no longer pre-creates it.

Verification

  • pnpm test — 62 passed (6 files), up from 57. New tests cover the path rewrite (pnpm, npm, and missing-target cases) and assert the unit declares RuntimeDirectory= and lists no tmpfs path.
  • pnpm build clean.
  • systemd-analyze verify on the rendered template reports no directive errors.

Note

This does not retroactively repair already-installed units. The affected host was fixed by hand; re-running sudo threatcrush install-service is what picks this up elsewhere.

🤖 Generated with Claude Code

https://claude.ai/code/session_018NXz7vRz6C7vaGSwMgWZfD

…d reboot

Two independent defects left `threatcrushd.service` permanently unstartable on
a real host — found at 6315 failed starts against a path last valid at 0.2.1.

`resolveBinPath()` returned `process.argv[1]`, which under a pnpm global install
is the version-stamped `.pnpm/@profullstack+threatcrush@X.Y.Z/...` directory.
The next upgrade moves that directory, so ExecStart points at nothing and
`Restart=on-failure` turns it into an endless loop. Rewrite it to the stable
symlink pnpm keeps at the store root, and only when that symlink really exists.

The unit also listed `/var/run/threatcrush` under ReadWritePaths. `/var/run` is
a symlink to the `/run` tmpfs, so the directory `ensureSystemDirs()` created at
install time was gone after the next reboot, and a missing ReadWritePaths entry
fails the unit 226/NAMESPACE on every start. Use `RuntimeDirectory=` so systemd
creates it per start, and stop pre-creating it.

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 bd6928b into master Aug 30, 2026
11 checks passed
@ralyodio
ralyodio deleted the fix/install-service-stable-path 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