Gracefully shutdown lighthouse boot node
This commit is contained in:
parent
aeff5085eb
commit
6fdad74e14
@ -18,13 +18,14 @@ 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
|
||||
|
||||
# See https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script
|
||||
cleanup() {
|
||||
echo "Signal received, cleaning up..."
|
||||
|
||||
# Kill the child process first (CERC_REMOTE_DEBUG=true uses dlv which starts geth as a child)
|
||||
# Kill the child process first (CERC_REMOTE_DEBUG=true uses dlv which starts geth as a child process)
|
||||
pkill -P ${geth_pid}
|
||||
sleep 3
|
||||
kill ${geth_pid}
|
||||
sleep 2
|
||||
kill $(jobs -p)
|
||||
|
||||
wait
|
||||
echo "Done"
|
||||
|
||||
@ -1,12 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# See https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script
|
||||
cleanup() {
|
||||
echo "Signal received, cleaning up..."
|
||||
kill $(jobs -p)
|
||||
|
||||
wait
|
||||
echo "Done"
|
||||
}
|
||||
trap 'cleanup' SIGINT SIGTERM
|
||||
|
||||
if [ "true" == "$RUN_BOOTNODE" ]; then
|
||||
cd /opt/testnet/build/cl
|
||||
python3 -m http.server 3000 &
|
||||
|
||||
|
||||
cd /opt/testnet/cl
|
||||
./bootnode.sh 2>&1 | tee /var/log/lighthouse_bootnode.log
|
||||
./bootnode.sh 2>&1 | tee /var/log/lighthouse_bootnode.log &
|
||||
bootnode_pid=$!
|
||||
|
||||
wait $bootnode_pid
|
||||
else
|
||||
while [ 1 -eq 1 ]; do
|
||||
echo "Waiting on geth ..."
|
||||
@ -58,26 +71,10 @@ 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=$!
|
||||
beacon_pid=$!
|
||||
./validator_client.sh 2>&1 | tee /var/log/lighthouse_vc.log &
|
||||
vpid=$!
|
||||
validator_pid=$!
|
||||
|
||||
wait $lpid $vpid
|
||||
wait $beacon_pid $validator_pid
|
||||
fi
|
||||
|
||||
|
||||
@ -117,8 +117,8 @@ Clear volumes created by this stack:
|
||||
|
||||
```bash
|
||||
# List all relevant volumes
|
||||
docker volume ls -q --filter "name=.*fixturenet_eth_bootnode_geth_data|.*fixturenet_eth_bootnode_lighthouse_data|.*fixturenet_eth_geth_1_data|.*fixturenet_eth_geth_2_data|.*fixturenet_eth_lighthouse_1_data|.*fixturenet_eth_lighthouse_2_data|.*fixturenet_geth_accounts"
|
||||
$ docker volume ls -q --filter "name=.*fixturenet_eth_bootnode_geth_data|.*fixturenet_eth_bootnode_lighthouse_data|.*fixturenet_eth_geth_1_data|.*fixturenet_eth_geth_2_data|.*fixturenet_eth_lighthouse_1_data|.*fixturenet_eth_lighthouse_2_data|.*fixturenet_geth_accounts"
|
||||
|
||||
# Remove all the listed volumes
|
||||
docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_eth_bootnode_geth_data|.*fixturenet_eth_bootnode_lighthouse_data|.*fixturenet_eth_geth_1_data|.*fixturenet_eth_geth_2_data|.*fixturenet_eth_lighthouse_1_data|.*fixturenet_eth_lighthouse_2_data|.*fixturenet_geth_accounts")
|
||||
$ docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_eth_bootnode_geth_data|.*fixturenet_eth_bootnode_lighthouse_data|.*fixturenet_eth_geth_1_data|.*fixturenet_eth_geth_2_data|.*fixturenet_eth_lighthouse_1_data|.*fixturenet_eth_lighthouse_2_data|.*fixturenet_geth_accounts")
|
||||
```
|
||||
|
||||
Loading…
Reference in New Issue
Block a user