Skip to content

Commit 844e230

Browse files
committed
cleanup
1 parent 1319c18 commit 844e230

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

cleanup.bash

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ set -uo pipefail
44
PARENT="${PARENT:?PARENT env var required}"
55
SERVICE_NAME="${K_SERVICE:?K_SERVICE env var required}"
66

7+
# =============================================
8+
# Cleanup / Crash Handler
9+
# =============================================
10+
cleanup() {
11+
EXIT_CODE=$?
12+
if [ $EXIT_CODE -ne 0 ]; then
13+
echo "=================================================================="
14+
echo "❌ SCRIPT CRASHED with exit code ${EXIT_CODE}"
15+
echo " This usually means something went wrong during health checking"
16+
echo " or during the delete operation."
17+
echo "=================================================================="
18+
else
19+
echo "Script finished normally."
20+
fi
21+
}
22+
23+
# Catch errors, interrupts, and normal exit
24+
trap cleanup EXIT
25+
trap 'echo "❌ Script interrupted (SIGINT)"; exit 1' INT
26+
trap 'echo "❌ Script terminated (SIGTERM)"; exit 1' TERM
27+
728
delete_service() {
829
echo "Flask appears down → Deleting service ${PARENT}/services/${SERVICE_NAME}"
930

@@ -40,4 +61,6 @@ while true; do
4061
delete_service
4162
break
4263
fi
43-
done
64+
done
65+
66+
echo "Health check loop ended."

0 commit comments

Comments
 (0)