Skip to content

Commit

Permalink
Update the script
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJeremyHe committed Jul 18, 2024
1 parent fa5b1ba commit 4ff6e8f
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions scripts/launch-dev-node-with-postgres
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

0 comments on commit 4ff6e8f

Please sign in to comment.