launch_local_testnet.sh: fix terminating Geth (#4684)

Also improve logging and list jobs after cleanup.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-03-01 17:27:55 +01:00 committed by GitHub
parent 3681177cf4
commit 2f36f15b20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 14 deletions

View File

@ -746,15 +746,15 @@ cleanup() {
echo "Existing processes:" echo "Existing processes:"
for proc in "${PROCS_TO_KILL[@]}"; do for proc in "${PROCS_TO_KILL[@]}"; do
PROC_NAME=$(basename "$proc") PROC_NAME=$(basename "$proc")
pgrep -alf "${PROC_NAME}" || true pgrep -al "${PROC_NAME}" || true
done done
echo "Terminating:" echo "Terminating:"
for proc in "${PROCS_TO_KILL[@]}"; do for proc in "${PROCS_TO_KILL[@]}"; do
PROC_NAME=$(basename "$proc") PROC_NAME=$(basename "$proc")
echo -n "Terminating ${PROC_NAME}: " >&2
# WARNING: The '-P $$' avoids killing unrelated processes. # WARNING: The '-P $$' avoids killing unrelated processes.
pkill -SIGTERM "${PKILL_ECHO_FLAG}" -P $$ "${PROC_NAME}" \ pkill -SIGTERM "${PKILL_ECHO_FLAG}" -P $$ "${PROC_NAME}" || true
|| echo "Nothing to terminate: ${PROC_NAME}"
done done
sleep 2 sleep 2
@ -762,9 +762,9 @@ cleanup() {
echo "Killing:" echo "Killing:"
for proc in "${PROCS_TO_KILL[@]}"; do for proc in "${PROCS_TO_KILL[@]}"; do
PROC_NAME=$(basename "$proc") PROC_NAME=$(basename "$proc")
echo -n "Killing ${PROC_NAME}: " >&2
# WARNING: The '-P $$' avoids killing unrelated processes. # WARNING: The '-P $$' avoids killing unrelated processes.
pkill -SIGKILL "${PKILL_ECHO_FLAG}" -P $$ "${PROC_NAME}" \ pkill -SIGKILL "${PKILL_ECHO_FLAG}" -P $$ "${PROC_NAME}" || true
|| echo "Nothing to kill: ${PROC_NAME}"
done done
# Delete all binaries we just built, because these are unusable outside this # Delete all binaries we just built, because these are unusable outside this
@ -786,6 +786,9 @@ cleanup() {
rm -rf "${dir}" rm -rf "${dir}"
done done
fi fi
echo "Jobs status after cleanup:"
jobs
} }
trap 'cleanup' SIGINT SIGTERM EXIT trap 'cleanup' SIGINT SIGTERM EXIT

View File

@ -12,11 +12,9 @@ GETH_ENODES=()
log "Using ${GETH_BINARY}" log "Using ${GETH_BINARY}"
start_geth_node() { for GETH_NODE_IDX in $(seq 0 $GETH_LAST_NODE_IDX); do
GETH_NODE_IDX=$1
mkdir -p "${GETH_DATA_DIRS[GETH_NODE_IDX]}" mkdir -p "${GETH_DATA_DIRS[GETH_NODE_IDX]}"
set -x set -x
${GETH_BINARY} version ${GETH_BINARY} version
${GETH_BINARY} --datadir "${GETH_DATA_DIRS[GETH_NODE_IDX]}" init "${EXECUTION_GENESIS_JSON}" ${GETH_BINARY} --datadir "${GETH_DATA_DIRS[GETH_NODE_IDX]}" init "${EXECUTION_GENESIS_JSON}"
${GETH_BINARY} \ ${GETH_BINARY} \
@ -27,12 +25,9 @@ start_geth_node() {
--http.port ${GETH_RPC_PORTS[GETH_NODE_IDX]} \ --http.port ${GETH_RPC_PORTS[GETH_NODE_IDX]} \
--port ${GETH_NET_PORTS[GETH_NODE_IDX]} \ --port ${GETH_NET_PORTS[GETH_NODE_IDX]} \
--authrpc.port ${GETH_AUTH_RPC_PORTS[GETH_NODE_IDX]} \ --authrpc.port ${GETH_AUTH_RPC_PORTS[GETH_NODE_IDX]} \
--authrpc.jwtsecret "${JWT_FILE}" --authrpc.jwtsecret "${JWT_FILE}" \
} &> "${DATA_DIR}/geth-log${GETH_NODE_IDX}.txt" &
set +x
for GETH_NODE_IDX in $(seq 0 $GETH_LAST_NODE_IDX); do
start_geth_node $GETH_NODE_IDX \
&> "${DATA_DIR}/geth-log${GETH_NODE_IDX}.txt" &
done done
for GETH_NODE_IDX in $(seq 0 $GETH_LAST_NODE_IDX); do for GETH_NODE_IDX in $(seq 0 $GETH_LAST_NODE_IDX); do