From 56378f13a33766f8461b3bd25f6bbbe3b3242514 Mon Sep 17 00:00:00 2001 From: LR-Coin <57722364+LR-Coin@users.noreply.github.com> Date: Sat, 10 Jan 2026 18:41:22 +0100 Subject: [PATCH] Create check_rpc_and_log.sh Adds a script that queries both L1 and L2 RPC endpoints, writes OK or ERROR to rpc_health.log, and includes a timestamp. --- scripts/check_rpc_and_log.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 scripts/check_rpc_and_log.sh diff --git a/scripts/check_rpc_and_log.sh b/scripts/check_rpc_and_log.sh new file mode 100644 index 00000000..c70d4459 --- /dev/null +++ b/scripts/check_rpc_and_log.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Check L1 and L2 JSON-RPC endpoints and log the results to a file. + +L1_RPC="${L1_RPC_URL:-http://localhost:8545}" +L2_RPC="${L2_RPC_URL:-http://localhost:9000}" +LOG_FILE="${LOG_FILE:-./rpc_health.log}" +TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S") + +check_rpc() { + local name="$1" + local url="$2" + if curl -s -H "Content-Type: application/json" \ + -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \ + "$url" >/dev/null; then + echo "$TIMESTAMP [$name] OK" >>"$LOG_FILE" + else + echo "$TIMESTAMP [$name] ERROR" >>"$LOG_FILE" + fi +} + +check_rpc "L1" "$L1_RPC" +check_rpc "L2" "$L2_RPC"