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