Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions scripts/check_rpc_and_log.sh
Original file line number Diff line number Diff line change
@@ -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"