Repository navigation
Conversation
scripts/start.sh was a fish script, so `bun run dev` and `bun run demo` needed fish installed. scripts/dev.ts does the same with Bun.spawn: the demo runs scripts/dev/setup.sh first and aborts if it fails, sets the sandbox's SNAPRAID_* variables (or creates ./snapraid without --demo), all paths from the repository's root, then runs `bun run dev` in apps/server and apps/web. Each runs in a process group of its own (as scripts/dev.ts in firsttris/ccu-addon-mui), and SIGINT, SIGTERM and SIGHUP go on to both groups, so a Ctrl+C, an IDE's stop or a closed terminal also stops what bun --watch and Vite started instead of leaving them on :8080 and :3000; what ignores SIGTERM gets SIGKILL after 5 s. When one exits, the other is stopped and its exit code is passed on; on a signal the script exits with 128 + n (130 for Ctrl+C), as before. scripts/dev.test.ts runs it against stand-ins for both apps and setup.sh; CI runs it in the backend job (`bun test ./scripts` in the root), and the backend's typecheck covers scripts/*.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y3rdfbWb1xDUdPRng7TX9Z
The server stand-in exited as soon as the web app's grandchild had written its pid, so dev.ts could stop the web app before the test had seen its processes alive, and running(['web']) failed now and then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y3rdfbWb1xDUdPRng7TX9Z
After the grace time dev.ts sends SIGKILL and exits right away, but the kernel takes a while to tear a process down, the longer the more memory it holds. The stand-in holds 1.5 GiB and ignores SIGTERM; the existing SIGKILL test fails now and then for the same reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y3rdfbWb1xDUdPRng7TX9Z
After SIGKILL dev.ts went on at once, so bun run dev could return while Vite or the backend were still being torn down (and still held their ports). It now polls the group for up to a second more; longer only an orphan's zombie can keep the group alive until init reaps it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y3rdfbWb1xDUdPRng7TX9Z
Bun's detached children run in sessions of their own, out of the terminal's reach, so its SIGTSTP stops only dev.ts; with scripts/start.sh on master Ctrl+Z stopped the servers too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y3rdfbWb1xDUdPRng7TX9Z
In sessions of their own the servers are out of the terminal's reach, so SIGTSTP stopped only dev.ts. dev.ts now stops their groups with SIGSTOP (the kernel drops SIGTSTP sent to an orphaned group, which a session of its own is) before stopping itself, and passes SIGCONT on, as haul's scripts/dev.ts does. Checked in a pty as well: fish scripts/start.sh and the fixed dev.ts both leave all processes in state T after Ctrl+Z. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y3rdfbWb1xDUdPRng7TX9Z
TDD-ReviewNur Befunde, die ein fehlschlagender Test belegt. Fixes sind als eigene Commits auf 1. Nach SIGKILL beendet sich dev.ts, bevor die Prozesse weg sind
Test: Fix 96b15ea: nach SIGKILL bis zu 1 s weiter pollen, bis die Gruppe weg ist (länger kann sie nur ein Zombie eines Waisen halten, bis init ihn abholt). 5/5 Läufe der Suite grün. 2. Ctrl+Z hält nur dev.ts an, beide Server laufen weiter (Regression gegenüber start.sh)
Test: Gegenprobe in einem echten pty (interaktive bash, Stand-ins für beide Apps), Zustände der Prozesse nach Fix 69481bd (wie in haul's 3. Testfehler:
|
|
Geschlossen: Statt eigener Signal- und Prozessgruppen-Logik ( Generated by Claude Code |
bun run devandbun run demoranscripts/start.sh, a fish script, so anyone without fish could not start the app. This replaces it withscripts/dev.ts(bun scripts/dev.ts [--demo]), so Bun is the only requirement.Behaviour kept from start.sh
--demo: runsbash scripts/dev/setup.shfirst and aborts with exit code 1 if it fails; setsSNAPRAID_BASE_PATH=scripts/dev/sandbox,SNAPRAID_BIN=scripts/dev/bin/snapraid,SNAPRAID_EXTRA_ARGS=--test-skip-device,SNAPRAID_DEMO=1.SNAPRAID_BASE_PATH=<root>/snapraid, created withmkdir -p.bun run devinapps/serverandapps/web. When one exits, the other is stopped. On SIGINT/SIGTERM it exits with 128 + n (130 for Ctrl+C).Changed or added
scripts/dev.ts). SIGINT, SIGTERM and SIGHUP go to both whole groups, so Ctrl+C, closing the terminal and an IDE's stop orkillall stop the grandchildren too (bun --watch, Vite/node). A group still running 5 s after the signal gets SIGKILL. The script waits until both groups are empty before it exits.ignore), so Vite's keyboard shortcuts are off.process.execPath).Tests:
scripts/dev.test.ts(bun:test, 8 tests). They run a copy of the script in a temporary copy of the repo layout, with stand-ins for both apps'bun run devand forsetup.sh. Each stand-in records the pids ofbun run, of its shell and of a grandchild. The tests cover:mkdirwithout--demo.I checked the tests against a mutant that signals only the direct child: 4 of them fail. CI runs them as a new step
bun test ./scripts(from the root) in the backend job. The server'sbun testkeeps its count (234 pass / 2 skip). The server'stsconfig.jsonnow includes../../scripts/*.ts, sobun run typecheckchecks the script.Docs: README and
docs/development.mdno longer list fish. The development docs describe how the script stops the servers and the new tests. The comments that mentionedstart.shnow point todev.ts.Checked locally
bun run dev::8080/api/healthreturned ok and:3000returned 200. SIGINT to the foreground process group (the same as Ctrl+C) stopped all processes in all three sessions within about 2 s, and both ports were closed afterwards.bun run demo: setup found the existing sandbox, the children got the fourSNAPRAID_*variables, and both servers were up. SIGHUP sent todev.tsalone left nothing running, and the exit code was 129.bun run dev, then SIGTERM sent todev.tsalone: nothing left running, and the exit code was 143.bun install --frozen-lockfile. In the server,bun test(234 pass / 2 skip) andtypecheckpassed. In the web app, biome,typecheck, 60 tests andbuildpassed.Generated by Claude Code