Skip to content

Commit

Permalink
launch_local_testnet.sh: fix terminating Geth (#4684)
Browse files Browse the repository at this point in the history
Also improve logging and list jobs after cleanup.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
  • Loading branch information
jakubgs authored Mar 1, 2023
1 parent 3681177 commit 2f36f15
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 8 additions & 5 deletions scripts/launch_local_testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -746,25 +746,25 @@ cleanup() {
echo "Existing processes:"
for proc in "${PROCS_TO_KILL[@]}"; do
PROC_NAME=$(basename "$proc")
pgrep -alf "${PROC_NAME}" || true
pgrep -al "${PROC_NAME}" || true
done

echo "Terminating:"
for proc in "${PROCS_TO_KILL[@]}"; do
PROC_NAME=$(basename "$proc")
echo -n "Terminating ${PROC_NAME}: " >&2
# WARNING: The '-P $$' avoids killing unrelated processes.
pkill -SIGTERM "${PKILL_ECHO_FLAG}" -P $$ "${PROC_NAME}" \
|| echo "Nothing to terminate: ${PROC_NAME}"
pkill -SIGTERM "${PKILL_ECHO_FLAG}" -P $$ "${PROC_NAME}" || true
done

sleep 2

echo "Killing:"
for proc in "${PROCS_TO_KILL[@]}"; do
PROC_NAME=$(basename "$proc")
echo -n "Killing ${PROC_NAME}: " >&2
# WARNING: The '-P $$' avoids killing unrelated processes.
pkill -SIGKILL "${PKILL_ECHO_FLAG}" -P $$ "${PROC_NAME}" \
|| echo "Nothing to kill: ${PROC_NAME}"
pkill -SIGKILL "${PKILL_ECHO_FLAG}" -P $$ "${PROC_NAME}" || true
done

# Delete all binaries we just built, because these are unusable outside this
Expand All @@ -786,6 +786,9 @@ cleanup() {
rm -rf "${dir}"
done
fi

echo "Jobs status after cleanup:"
jobs
}

trap 'cleanup' SIGINT SIGTERM EXIT
Expand Down
13 changes: 4 additions & 9 deletions scripts/start_geth_nodes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ GETH_ENODES=()

log "Using ${GETH_BINARY}"

start_geth_node() {
GETH_NODE_IDX=$1
for GETH_NODE_IDX in $(seq 0 $GETH_LAST_NODE_IDX); do
mkdir -p "${GETH_DATA_DIRS[GETH_NODE_IDX]}"
set -x

${GETH_BINARY} version
${GETH_BINARY} --datadir "${GETH_DATA_DIRS[GETH_NODE_IDX]}" init "${EXECUTION_GENESIS_JSON}"
${GETH_BINARY} \
Expand All @@ -27,12 +25,9 @@ start_geth_node() {
--http.port ${GETH_RPC_PORTS[GETH_NODE_IDX]} \
--port ${GETH_NET_PORTS[GETH_NODE_IDX]} \
--authrpc.port ${GETH_AUTH_RPC_PORTS[GETH_NODE_IDX]} \
--authrpc.jwtsecret "${JWT_FILE}"
}

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" &
--authrpc.jwtsecret "${JWT_FILE}" \
&> "${DATA_DIR}/geth-log${GETH_NODE_IDX}.txt" &
set +x
done

for GETH_NODE_IDX in $(seq 0 $GETH_LAST_NODE_IDX); do
Expand Down

0 comments on commit 2f36f15

Please sign in to comment.