From b33e5e425aa8ca708ab556e429dabe668e04a99f Mon Sep 17 00:00:00 2001 From: counterweight Date: Sun, 21 Dec 2025 23:17:17 +0100 Subject: [PATCH] Add trap for cleanup in e2e.sh script - Added cleanup function to kill background processes - Trap on EXIT ensures cleanup happens on normal exit, errors, or Ctrl+C - Prevents orphaned backend/worker processes if script is interrupted --- scripts/e2e.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/e2e.sh b/scripts/e2e.sh index 32cdbf1..df4375d 100755 --- a/scripts/e2e.sh +++ b/scripts/e2e.sh @@ -3,6 +3,15 @@ set -e cd "$(dirname "$0")/.." +# Cleanup function to kill background processes +cleanup() { + kill $BACKEND_PID 2>/dev/null || true + kill $WORKER_PID 2>/dev/null || true +} + +# Ensure cleanup runs on exit (normal, error, or interrupt) +trap cleanup EXIT + # Load environment variables if .env exists if [ -f .env ]; then set -a @@ -49,9 +58,6 @@ else fi EXIT_CODE=$? -# Cleanup -kill $BACKEND_PID 2>/dev/null || true -kill $WORKER_PID 2>/dev/null || true - +# Cleanup is handled by trap EXIT exit $EXIT_CODE