diff --git a/scripts/launch-dev-node-with-postgres b/scripts/launch-dev-node-with-postgres index 9830a7a677..97156754e9 100644 --- a/scripts/launch-dev-node-with-postgres +++ b/scripts/launch-dev-node-with-postgres @@ -11,22 +11,11 @@ export POSTGRES_PASSWORD=$ESPRESSO_SEQUENCER_POSTGRES_PASSWORD export RUST_LOG=${RUST_LOG:-info} -# Function to handle SIGTERM and SIGINT -cleanup() { - echo "Received SIGTERM or SIGINT. Exiting..." - kill -TERM "$postgres_pid" 2>/dev/null - kill -TERM "$dev_node_pid" 2>/dev/null - wait "$postgres_pid" - wait "$dev_node_pid" - exit 0 -} - -# Trap SIGTERM and SIGINT signals -trap cleanup SIGTERM SIGINT +# Trap SIGTERM and SIGINT signals and send them to the process group +trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT # Start postgres in the background docker-entrypoint.sh postgres & -postgres_pid=$! # Wait (twice) for postgres to be ready # Postgres can be falsely "ready" once before running init scripts. @@ -37,8 +26,4 @@ done # Start the dev node espresso-dev-node & -dev_node_pid=$! - -# Wait for child processes to exit -wait "$postgres_pid" -wait "$dev_node_pid" +wait