Skip to content

Commit 061cdb1

Browse files
committed
Trap EXIT
1 parent e323dd3 commit 061cdb1

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,15 @@ jobs:
233233
-e EPHEMERAL=true \
234234
-e DISABLE_AUTO_UPDATE=true \
235235
${GH_RUNNER_IMAGE} 10
236+
237+
- name: Test EXIT trap on crash
238+
run: |
239+
# Run the container with a dummy token and force it to exit with code 1
240+
docker run --name trap-test \
241+
-e REPO_URL=https://github.com/fake/repo \
242+
-e RUNNER_TOKEN=faketoken \
243+
-e DISABLE_AUTOMATIC_DEREGISTRATION=false \
244+
${GH_RUNNER_IMAGE} /bin/bash -c "exit 1" || true
245+
246+
# Check the logs to ensure the trap fired
247+
docker logs trap-test | grep "Caught EXIT - Deregistering runner"

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ fi
236236

237237
if [[ ${_DISABLE_AUTOMATIC_DEREGISTRATION} == "false" ]]; then
238238
if [[ ${_DEBUG_ONLY} == "false" ]]; then
239-
trap_with_arg deregister_runner SIGINT SIGQUIT SIGTERM INT TERM QUIT
239+
trap_with_arg deregister_runner SIGINT SIGQUIT SIGTERM INT TERM QUIT EXIT
240240
fi
241241
fi
242242

0 commit comments

Comments
 (0)