Skip to content

start-all: exit when any service dies, so launchd actually restarts the stack - #84

Merged
ThinkOffApp merged 1 commit into
mainfrom
fix/start-all-dies-with-any-service
Aug 30, 2026
Merged

ThinkOffApp merged 1 commit into
mainfrom
fix/start-all-dies-with-any-service

Conversation

@ThinkOffApp

Copy link
Copy Markdown
Owner

Today the confirmations daemon died on the Mini and nothing brought it back. start-all.sh kept running, launchd saw a healthy job, and the room lost approval routing and message notifications until a human noticed and ran launchctl kickstart.

Cause: the script ends in a bare wait, which returns only when every child has exited. A single dead service is invisible to it. That daemon holds :8788 and settles every Approve/Deny tap, so it is the most expensive process in the file and was the least visible when it went.

Fix: collect each service's pid and supervise them in a loop; the moment one stops, kill the siblings and exit non-zero so launchd's KeepAlive restarts the stack as a unit. wait -n would be the one-liner, but macOS ships bash 3.2, which does not have it — kill -0 polling works everywhere and costs nothing at a 5s interval.

Verified, not just reasoned about: a mock with the same structure and three children. Killing one made the supervisor exit within the poll interval, take its siblings with it, and leave zero orphans. bash -n clean.

Note this is the second supervision gap found today — the antfarm bridge has a KeepAlive plist that is not loaded, so it is unsupervised too. Different repo, filed separately.

@codexmb worth a look.

2026-08-30: the confirmations daemon died on this Mini. Nothing restarted it.
start-all.sh carried on, launchd saw a healthy job, and the room's approval
routing and message notifications were simply gone until a human noticed and
ran 'launchctl kickstart'. That daemon holds :8788 and settles every
Approve/Deny tap, so its death is the most expensive one in this file and was
the least visible.

Cause: a bare 'wait' returns only when EVERY child has exited. One dead
service is invisible to it.

Now each service's pid is collected and a supervisor loop exits as soon as one
of them stops, killing the siblings so launchd's KeepAlive brings the whole
stack back together. 'wait -n' would be the one-liner but macOS ships bash 3.2
and does not have it; polling with kill -0 works everywhere.

Verified with a mock of the same structure: killing one child made the
supervisor exit non-zero within the poll interval, take its siblings with it,
and leave no orphans. bash -n clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

@ThinkOffApp
ThinkOffApp merged commit 934d7fd into main Aug 30, 2026
3 checks passed
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