chore(dev-stack): drop the two kill calls that never matched anything - #209
Conversation
`down` carried two fallbacks that looked like they stopped the dApp dev server. Neither ever ran against a real process: - `pkill -f "vite --host localhost --port 3012"` matched nothing. The real argv is `node .../vite.js` with no flags, because host, port and strictPort are set in `dapp/frontend/vite.config.ts`. - `pkill -P "$pid"` signals only direct children, and vite sits two levels down: `pnpm run app:dev` spawns `pnpm -C dapp/frontend run dev`, which spawns vite. Removing them changes no behaviour. The plain `kill "$pid"` already stops the whole chain, because pnpm forwards SIGTERM to what it spawned. The comment above it claimed the code killed a process group, which it never did, so it now says what actually happens. Checked by running the script end to end: docker-up, up, down. The stack came up with 3010 and 3012 both answering, and after `down` nothing held 3010-3013 and no vite or pnpm process was left behind. Refs #188
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
fernandomg
left a comment
There was a problem hiding this comment.
I've been facing the same problem during local runs, and reached a different solution.
CC Report
The premise doesn't hold: killing the pid on file doesn't reach vite. The pidfile holds the outer pnpm run app:dev; vite is two levels down (pnpm run app:dev → pnpm -C dapp/frontend run dev → vite.js). Same shape, no ports involved:
{ "scripts": { "outer": "pnpm run inner", "inner": "node -e \"setInterval(()=>{},1000)\"" } }nohup pnpm run outer & PID=$!; sleep 3; kill $PID; sleep 2; pgrep -f setInterval # still runningThe grandchild survives under pnpm 11.24.0 (our pin) and 12.3.4. So down reaches less after this PR than before — the removed pkill -P at least took the direct child.
Agreed on the pkill -f "vite --host …" line: vite's argv is …/vite/bin/vite.js --host …, so it never matched. Removing it is right.
A down that works regardless of the process tree kills by port instead: lsof -t -iTCP:3012 -sTCP:LISTEN, filtered to listeners whose cwd is this checkout so another checkout's stack is left alone.
The pidfile kill handles the normal case, but nothing covered a listener no pidfile knows about: a crashed `up`, or a dev server someone started by hand. `down` then reported the port busy and left the user to find the pid. - `stop_port` looks up listeners with `lsof -t` and kills them - It only kills a pid whose cwd is inside this checkout, so another clone running its own stack is untouched - `down` calls it for 3010 and 3012 after the two `stop_pidfile` calls Checked on a full run: with the stack up it prints nothing, because the pidfile kills already freed both ports. With an untracked dev server on 3012 it frees the port. With a listener whose cwd is outside the checkout it leaves the process alone and the port report shows 3012 still in use.
|
My CC's answer to this... Ran the full loop through The kill already reaches Vite
With the stack up, the pidfile held the outer
Also ran your minimal The What I took from your suggestionKilling by port is worth having, just not for the reported symptom: it covers the case no pidfile can: a crashed Added in 4d17826
One detail worth knowing: the cwd match has to be a prefix. wallet-service runs from the repo root, vite from Three cases checked on a full
shellcheck is clean. Teardown verified: no containers, no survivors, 3010-3012 free. |
Summary
Closes #188
The issue reports that
downleaves the dApp dev server holding 3012. Running the full stack showed the port is freed. What it did find is two kill calls that reach no process at all.Changes
downno longer runs apkillpattern that matched nothingstop_pidfileno longer runs apkill -Pthat never reached vitekillsays what actually stops the dev serverDeviations
killalready stops the whole chain, so nothing leaked. Worth editing dev-stack.sh down leaves the dApp dev server holding port 3012 #188 to say the code was dead, not broken.Acceptance criteria
downfrees 3010-3012 and its port report prints(all free)Test plan
Automated tests
None. No test runner covers
scripts/dev-stack.sh.Manual verification
./scripts/dev-stack.sh docker-up./scripts/dev-stack.sh upand wait for "Stack is up"./scripts/dev-stack.sh down(all free)lsof -nP -iTCP:3010-3012 -sTCP:LISTENand expect no outputBreaking changes
None.
Checklist
Screenshots
None.