Repository navigation
fix(server): keep the server up when a stray signal reaches it - #580
Merged
Merged
Conversation
A dev session stopped while an agent was using browser automation: the Vite process received a SIGTERM from outside, and the dev runner (concurrently, killOthersOn: failure) took that 143 as a failure and shut the backend down with it. The sender could not be identified (the OS does not record it). In production the launcher, the server and every engine process shared one process group, so a group signal would end the whole app the same way. Add one supervisor for the production launcher and the dev runner. It runs each child in its own process group (POSIX) and restarts a child that exits without being asked to, whatever its exit code, giving up after 5 restarts in 60 s. It forwards SIGINT/SIGTERM to the child's group with 15 s to shut down, and ignores SIGHUP as the server does. Each unrequested exit is logged with the processes started just before it, to the console and <data-dir>/logs/supervisor.log. The dev runner supervises backend and frontend separately and no longer uses concurrently.
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
Supervise the Clopen server (production launcher) and the dev backend/frontend so a stray signal no longer takes the app down: each runs in its own process group and is restarted if it stops without being asked to.
Why
A dev session ended while an agent ran browser automation:
vite devreceived a SIGTERM from an unknown sender, andconcurrently(killOthersOn: failure) treated the 143 as a failure and stopped the backend. In production,bun clopen, the server and every engine process shared one process group, so a signal to that group would end the whole app. The fix is in Clopen alone, so it covers every engine.Changes
shared/utils/process-supervisor.ts:<data-dir>/logs/supervisor.log.bin/clopen.ts: the server runs under the supervisor; stdin isignore(the server never reads it).scripts/dev.ts: backend and frontend supervised independently with prefixed, colored output;concurrentlyremoved.Test plan
bun run check,bun run lintbun run test: 1936 pass; the 2renderScopeConfigfailures also fail onmainbun run dev: Ctrl+C stops both;kill <vite pid>restarts vite only and the backend stays upclopen: Ctrl+C stops cleanly;kill <server pid>restarts the server; closing the terminal leaves it runningNotes