Trap signals on shutdown and clean up in lighthouse nodes

This commit is contained in:
Prathamesh Musale 2023-04-18 12:23:06 +05:30
parent 384ca94fd6
commit 6e93ab4eb0
4 changed files with 20 additions and 3 deletions

View File

@ -13,13 +13,14 @@ cd /opt/testnet/build/el
python3 -m http.server 9898 &
cd $HOME_DIR
START_CMD="geth --datadir=~/ethdata"
START_CMD="geth"
if [ "true" == "$CERC_REMOTE_DEBUG" ] && [ -x "/usr/local/bin/dlv" ]; then
START_CMD="/usr/local/bin/dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient exec /usr/local/bin/geth --continue --"
fi
if [ "true" == "$RUN_BOOTNODE" ]; then
$START_CMD \
--datadir=~/ethdata \
--nodekeyhex="${BOOTNODE_KEY}" \
--nodiscover \
--ipcdisable \
@ -74,6 +75,7 @@ else
fi
$START_CMD \
--datadir=~/ethdata \
--bootnodes="${ENODE}" \
--allow-insecure-unlock \
--http \

View File

@ -19,9 +19,9 @@ http_port=8001
authrpc_port=8551
exec lighthouse \
--debug-level $DEBUG_LEVEL \
bn \
$SUBSCRIBE_ALL_SUBNETS \
--debug-level $DEBUG_LEVEL \
--boot-nodes "$ENR" \
--datadir $data_dir \
--testnet-dir $TESTNET_DIR \

View File

@ -21,9 +21,9 @@ while getopts "pd:" flag; do
done
exec lighthouse \
--debug-level $DEBUG_LEVEL \
vc \
$BUILDER_PROPOSALS \
--debug-level $DEBUG_LEVEL \
--validators-dir $DATADIR/node_$NODE_NUMBER/validators \
--secrets-dir $DATADIR/node_$NODE_NUMBER/secrets \
--testnet-dir $TESTNET_DIR \

View File

@ -58,6 +58,21 @@ else
export JWTSECRET="/opt/testnet/build/cl/jwtsecret"
echo -n "$JWT" > $JWTSECRET
# See https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script
cleanup() {
echo "Signal received, cleaning up..."
beacon_node_pid=$(pgrep -o -f 'lighthouse bn')
validator_client_pid=$(pgrep -o -f 'lighthouse vc')
kill ${beacon_node_pid}
kill ${validator_client_pid}
wait
echo "Done"
}
trap 'cleanup' SIGINT SIGTERM
./beacon_node.sh 2>&1 | tee /var/log/lighthouse_bn.log &
lpid=$!
./validator_client.sh 2>&1 | tee /var/log/lighthouse_vc.log &