Catch SIGINT/SIGTERM/SIGHUP in start-runner.sh so the VM always powers off#133
Open
ophirt wants to merge 1 commit into
Open
Catch SIGINT/SIGTERM/SIGHUP in start-runner.sh so the VM always powers off#133ophirt wants to merge 1 commit into
ophirt wants to merge 1 commit into
Conversation
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.
Problem
start-runner.shpowers the VM off when the runner exits, so Tartelet can recreate a fresh ephemeral VM:The script is launched inside a GUI Terminal session (
open -a Terminal ~/start-runner.sh). If that session is torn down — or the runner process is otherwise terminated by a signal — the shell receivesSIGHUP/SIGTERM, and a zshEXITtrap does not run when the shell is killed by a signal. Soonexitnever fires,shutdown -h nownever runs, and the VM stays powered on with no runner.Because Tartelet only provisions a replacement VM after it observes the current one stop, such a VM becomes a permanent "offline zombie": it shows offline in GitHub's runners page indefinitely and is never recycled, silently shrinking the pool while healthy VMs absorb all jobs.
We hit this in production: a runner died ~3s into boot with an I/O error on its console (the Terminal session went away before it reached "Listening for Jobs"),
start-runner.shgotSIGTERM, theEXITtrap was skipped, and the VM never powered off.Fix
Trap the termination signals too, so
onexit(and thereforeshutdown -h now) runs whether the shell exits normally or is killed by a signal:onexitonly runssudo shutdown -h now, so invoking it on a signal (and again on the subsequentEXIT) is idempotent — the machine is halting either way.Notes
start-runner.shheredoc; no Swift API or type changes.🤖 Generated with Claude Code