launch_local_testnet.sh: start the timeout earlier (#2753)
This commit is contained in:
parent
b3ff184537
commit
ca96a98131
|
@ -227,6 +227,37 @@ fi
|
||||||
|
|
||||||
$MAKE -j ${NPROC} LOG_LEVEL="${LOG_LEVEL}" NIMFLAGS="${NIMFLAGS} -d:testnet_servers_image -d:local_testnet -d:const_preset=${CONST_PRESET}" ${BINARIES}
|
$MAKE -j ${NPROC} LOG_LEVEL="${LOG_LEVEL}" NIMFLAGS="${NIMFLAGS} -d:testnet_servers_image -d:local_testnet -d:const_preset=${CONST_PRESET}" ${BINARIES}
|
||||||
|
|
||||||
|
# Kill child processes on Ctrl-C/SIGTERM/exit, passing the PID of this shell
|
||||||
|
# instance as the parent and the target process name as a pattern to the
|
||||||
|
# "pkill" command.
|
||||||
|
cleanup() {
|
||||||
|
pkill -f -P $$ nimbus_beacon_node &>/dev/null || true
|
||||||
|
pkill -f -P $$ nimbus_validator_client &>/dev/null || true
|
||||||
|
sleep 2
|
||||||
|
pkill -f -9 -P $$ nimbus_beacon_node &>/dev/null || true
|
||||||
|
pkill -f -9 -P $$ nimbus_validator_client &>/dev/null || true
|
||||||
|
|
||||||
|
# Delete the binaries we just built, because these are unusable outside this
|
||||||
|
# local testnet.
|
||||||
|
for BINARY in ${BINARIES}; do
|
||||||
|
rm build/${BINARY}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
trap 'cleanup' SIGINT SIGTERM EXIT
|
||||||
|
|
||||||
|
# timeout - implemented with a background job
|
||||||
|
timeout_reached() {
|
||||||
|
echo -e "\nTimeout reached. Aborting.\n"
|
||||||
|
cleanup
|
||||||
|
}
|
||||||
|
trap 'timeout_reached' SIGALRM
|
||||||
|
|
||||||
|
if [[ "${TIMEOUT_DURATION}" != "0" ]]; then
|
||||||
|
export PARENT_PID=$$
|
||||||
|
( sleep ${TIMEOUT_DURATION} && kill -ALRM ${PARENT_PID} ) 2>/dev/null & WATCHER_PID=$!
|
||||||
|
fi
|
||||||
|
|
||||||
|
# deposit and testnet creation
|
||||||
PIDS=""
|
PIDS=""
|
||||||
WEB3_ARG=""
|
WEB3_ARG=""
|
||||||
BOOTSTRAP_TIMEOUT=30 # in seconds
|
BOOTSTRAP_TIMEOUT=30 # in seconds
|
||||||
|
@ -306,24 +337,6 @@ DEPOSIT_CONTRACT_ADDRESS: ${DEPOSIT_CONTRACT_ADDRESS}
|
||||||
ETH1_FOLLOW_DISTANCE: 1
|
ETH1_FOLLOW_DISTANCE: 1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Kill child processes on Ctrl-C/SIGTERM/exit, passing the PID of this shell
|
|
||||||
# instance as the parent and the target process name as a pattern to the
|
|
||||||
# "pkill" command.
|
|
||||||
cleanup() {
|
|
||||||
pkill -f -P $$ nimbus_beacon_node &>/dev/null || true
|
|
||||||
pkill -f -P $$ nimbus_validator_client &>/dev/null || true
|
|
||||||
sleep 2
|
|
||||||
pkill -f -9 -P $$ nimbus_beacon_node &>/dev/null || true
|
|
||||||
pkill -f -9 -P $$ nimbus_validator_client &>/dev/null || true
|
|
||||||
|
|
||||||
# Delete the binaries we just built, because these are unusable outside this
|
|
||||||
# local testnet.
|
|
||||||
for BINARY in ${BINARIES}; do
|
|
||||||
rm build/${BINARY}
|
|
||||||
done
|
|
||||||
}
|
|
||||||
trap 'cleanup' SIGINT SIGTERM EXIT
|
|
||||||
|
|
||||||
dump_logs() {
|
dump_logs() {
|
||||||
LOG_LINES=20
|
LOG_LINES=20
|
||||||
for LOG in "${DATA_DIR}"/log*.txt; do
|
for LOG in "${DATA_DIR}"/log*.txt; do
|
||||||
|
@ -454,6 +467,9 @@ done
|
||||||
# give the regular nodes time to crash
|
# give the regular nodes time to crash
|
||||||
sleep 5
|
sleep 5
|
||||||
BG_JOBS="$(jobs | wc -l | tr -d ' ')"
|
BG_JOBS="$(jobs | wc -l | tr -d ' ')"
|
||||||
|
if [[ "${TIMEOUT_DURATION}" != "0" ]]; then
|
||||||
|
BG_JOBS=$(( BG_JOBS - 1 )) # minus the timeout bg job
|
||||||
|
fi
|
||||||
if [[ "$BG_JOBS" != "$NUM_JOBS" ]]; then
|
if [[ "$BG_JOBS" != "$NUM_JOBS" ]]; then
|
||||||
echo "$(( NUM_JOBS - BG_JOBS )) nimbus_beacon_node/nimbus_validator_client instance(s) exited early. Aborting."
|
echo "$(( NUM_JOBS - BG_JOBS )) nimbus_beacon_node/nimbus_validator_client instance(s) exited early. Aborting."
|
||||||
dump_logs
|
dump_logs
|
||||||
|
@ -461,18 +477,6 @@ if [[ "$BG_JOBS" != "$NUM_JOBS" ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# timeout - implemented with a background job
|
|
||||||
timeout_reached() {
|
|
||||||
echo -e "\nTimeout reached. Aborting.\n"
|
|
||||||
cleanup
|
|
||||||
}
|
|
||||||
trap 'timeout_reached' SIGALRM
|
|
||||||
|
|
||||||
if [[ "${TIMEOUT_DURATION}" != "0" ]]; then
|
|
||||||
export PARENT_PID=$$
|
|
||||||
( sleep ${TIMEOUT_DURATION} && kill -ALRM ${PARENT_PID} ) 2>/dev/null & WATCHER_PID=$!
|
|
||||||
fi
|
|
||||||
|
|
||||||
# launch htop or wait for background jobs
|
# launch htop or wait for background jobs
|
||||||
if [[ "$USE_HTOP" == "1" ]]; then
|
if [[ "$USE_HTOP" == "1" ]]; then
|
||||||
htop -p "$PIDS"
|
htop -p "$PIDS"
|
||||||
|
|
Loading…
Reference in New Issue