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
This commit is contained in:
parent
a8ad6e6384
commit
b33e5e425a
1 changed files with 10 additions and 4 deletions
|
|
@ -3,6 +3,15 @@ set -e
|
||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
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
|
# Load environment variables if .env exists
|
||||||
if [ -f .env ]; then
|
if [ -f .env ]; then
|
||||||
set -a
|
set -a
|
||||||
|
|
@ -49,9 +58,6 @@ else
|
||||||
fi
|
fi
|
||||||
EXIT_CODE=$?
|
EXIT_CODE=$?
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup is handled by trap EXIT
|
||||||
kill $BACKEND_PID 2>/dev/null || true
|
|
||||||
kill $WORKER_PID 2>/dev/null || true
|
|
||||||
|
|
||||||
exit $EXIT_CODE
|
exit $EXIT_CODE
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue