From 5d76b86d0cb0103ef6d059bd1d5a7926a1450813 Mon Sep 17 00:00:00 2001 From: Sebastian <379651+czarly@users.noreply.github.com> Date: Mon, 5 Aug 2024 17:21:19 +0200 Subject: [PATCH] restart on failure --- op-zircuit-mainnet.maintenance | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/op-zircuit-mainnet.maintenance b/op-zircuit-mainnet.maintenance index cc53bade..bac1e1a5 100644 --- a/op-zircuit-mainnet.maintenance +++ b/op-zircuit-mainnet.maintenance @@ -2,6 +2,16 @@ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# Check if "segmentation violation" is in the logs +if docker logs rpc-op-zircuit-1 2>&1 | grep -q "segmentation violation"; then + # Navigate to the specified directory + cd $script_dir || exit + # Recreate the service + docker compose up -d --force-recreate op-zircuit-node op-zircuit +else + echo "No segmentation violation found in the logs." +fi + PEERS=$(docker exec rpc-op-zircuit-node-1 sh -c "apk add curl > /dev/null; curl -s -X POST -H \"Content-Type: application/json\" --data '{\"jsonrpc\":\"2.0\",\"method\":\"opp2p_peers\",\"params\":[true],\"id\":1}' http://localhost:8545" | jq '.result.peers | keys | length') if [ "$PEERS" -eq 0 ]; then @@ -10,4 +20,4 @@ if [ "$PEERS" -eq 0 ]; then # Run the Docker Compose command docker compose up -d --force-recreate op-zircuit-node -fi \ No newline at end of file +fi