Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
223 lines
8.5 KiB
Bash
Executable File
223 lines
8.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Load IP configuration
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
|
|
|
|
|
|
# Immediate fix for explorer 502 errors
|
|
# This script fixes the Blockscout service and nginx configuration on VMID 5000
|
|
# Usage: Run from Proxmox host: ./fix-explorer-502-immediate.sh
|
|
|
|
set -e
|
|
|
|
VMID=5000
|
|
BLOCKSCOUT_PORT=4000
|
|
BLOCKSCOUT_IP="${IP_BLOCKSCOUT}"
|
|
|
|
echo "=========================================="
|
|
echo "Immediate Fix for Explorer 502 Errors"
|
|
echo "=========================================="
|
|
echo "VMID: $VMID ($BLOCKSCOUT_IP)"
|
|
echo "Target: Fix Blockscout service and nginx"
|
|
echo "=========================================="
|
|
echo ""
|
|
|
|
# Step 1: Check and start Blockscout service
|
|
echo "=== Step 1: Checking Blockscout Service ==="
|
|
SERVICE_STATUS=$(pct exec $VMID -- systemctl is-active blockscout.service 2>/dev/null || echo "inactive")
|
|
if [ "$SERVICE_STATUS" != "active" ]; then
|
|
echo "⚠️ Blockscout service is not running, starting..."
|
|
pct exec $VMID -- systemctl start blockscout.service || true
|
|
sleep 5
|
|
|
|
# Check again
|
|
SERVICE_STATUS=$(pct exec $VMID -- systemctl is-active blockscout.service 2>/dev/null || echo "inactive")
|
|
if [ "$SERVICE_STATUS" = "active" ]; then
|
|
echo "✅ Blockscout service started"
|
|
else
|
|
echo "❌ Failed to start Blockscout service"
|
|
echo " Check logs: pct exec $VMID -- journalctl -u blockscout.service -n 50"
|
|
fi
|
|
else
|
|
echo "✅ Blockscout service is running"
|
|
fi
|
|
echo ""
|
|
|
|
# Step 2: Check Blockscout Docker containers
|
|
echo "=== Step 2: Checking Blockscout Containers ==="
|
|
DOCKER_PS=$(pct exec $VMID -- docker ps --format '{{.Names}}: {{.Status}}' 2>/dev/null | grep blockscout | grep -v postgres || echo "")
|
|
if [ -n "$DOCKER_PS" ]; then
|
|
echo "✅ Blockscout containers running:"
|
|
echo "$DOCKER_PS" | sed 's/^/ /'
|
|
else
|
|
echo "⚠️ No Blockscout containers running"
|
|
echo " Check docker-compose.yml or docker containers"
|
|
fi
|
|
echo ""
|
|
|
|
# Step 3: Check port 4000
|
|
echo "=== Step 3: Checking Port $BLOCKSCOUT_PORT ==="
|
|
PORT_CHECK=$(pct exec $VMID -- ss -tlnp 2>/dev/null | grep :$BLOCKSCOUT_PORT || echo "not listening")
|
|
if echo "$PORT_CHECK" | grep -q ":$BLOCKSCOUT_PORT"; then
|
|
echo "✅ Port $BLOCKSCOUT_PORT is listening"
|
|
echo " Details: $PORT_CHECK"
|
|
|
|
# Check if listening on localhost only
|
|
if echo "$PORT_CHECK" | grep -q "127.0.0.1:$BLOCKSCOUT_PORT"; then
|
|
echo " ⚠️ Listening on localhost only (127.0.0.1)"
|
|
echo " ✅ This is OK for nginx proxy (nginx can reach localhost)"
|
|
elif echo "$PORT_CHECK" | grep -q "0.0.0.0:$BLOCKSCOUT_PORT\|:$BLOCKSCOUT_PORT.*0.0.0.0"; then
|
|
echo " ✅ Listening on all interfaces (0.0.0.0)"
|
|
fi
|
|
else
|
|
echo "❌ Port $BLOCKSCOUT_PORT is NOT listening"
|
|
echo " Blockscout may not be running or not configured on port $BLOCKSCOUT_PORT"
|
|
fi
|
|
echo ""
|
|
|
|
# Step 4: Test localhost API
|
|
echo "=== Step 4: Testing Blockscout API (localhost) ==="
|
|
LOCAL_TEST=$(pct exec $VMID -- curl -s -o /dev/null -w '%{http_code}' --connect-timeout 5 http://127.0.0.1:$BLOCKSCOUT_PORT/api/v2/stats 2>/dev/null || echo "000")
|
|
if [ "$LOCAL_TEST" = "200" ]; then
|
|
echo "✅ Blockscout API responding on localhost (HTTP $LOCAL_TEST)"
|
|
LOCAL_ACCESSIBLE=true
|
|
else
|
|
echo "❌ Blockscout API NOT responding on localhost (HTTP $LOCAL_TEST)"
|
|
echo " This is the root cause of the 502 error!"
|
|
echo " nginx cannot reach Blockscout on localhost:$BLOCKSCOUT_PORT"
|
|
LOCAL_ACCESSIBLE=false
|
|
fi
|
|
echo ""
|
|
|
|
# Step 5: Check nginx configuration
|
|
echo "=== Step 5: Checking Nginx Configuration ==="
|
|
NGINX_STATUS=$(pct exec $VMID -- systemctl is-active nginx 2>/dev/null || echo "inactive")
|
|
if [ "$NGINX_STATUS" != "active" ]; then
|
|
echo "⚠️ Nginx is not running, starting..."
|
|
pct exec $VMID -- systemctl start nginx || true
|
|
sleep 2
|
|
echo "✅ Nginx started"
|
|
else
|
|
echo "✅ Nginx is running"
|
|
fi
|
|
|
|
# Check nginx config
|
|
NGINX_CONFIG=$(pct exec $VMID -- cat /etc/nginx/sites-enabled/blockscout 2>/dev/null || pct exec $VMID -- cat /etc/nginx/sites-enabled/default 2>/dev/null || echo "not found")
|
|
if echo "$NGINX_CONFIG" | grep -q "proxy_pass.*127.0.0.1:$BLOCKSCOUT_PORT\|proxy_pass.*localhost:$BLOCKSCOUT_PORT"; then
|
|
echo "✅ Nginx configured to proxy to port $BLOCKSCOUT_PORT"
|
|
else
|
|
echo "⚠️ Nginx may not be configured to proxy to port $BLOCKSCOUT_PORT"
|
|
echo " Check nginx configuration for proxy_pass"
|
|
fi
|
|
|
|
# Test nginx config
|
|
if pct exec $VMID -- nginx -t 2>/dev/null | grep -q "test is successful"; then
|
|
echo "✅ Nginx configuration is valid"
|
|
else
|
|
echo "❌ Nginx configuration has errors"
|
|
pct exec $VMID -- nginx -t 2>&1 | sed 's/^/ /'
|
|
fi
|
|
echo ""
|
|
|
|
# Step 6: Fix nginx configuration if needed
|
|
if [ "$LOCAL_ACCESSIBLE" = false ]; then
|
|
echo "=== Step 6: Fixing Blockscout Connection ==="
|
|
echo "Blockscout is not accessible on localhost:$BLOCKSCOUT_PORT"
|
|
echo ""
|
|
echo "Possible fixes:"
|
|
echo "1. Check Blockscout docker-compose.yml or service configuration"
|
|
echo "2. Ensure Blockscout is bound to port $BLOCKSCOUT_PORT"
|
|
echo "3. Check if Blockscout service actually started"
|
|
echo ""
|
|
echo "Check logs:"
|
|
echo " pct exec $VMID -- journalctl -u blockscout.service -n 50"
|
|
echo " pct exec $VMID -- docker logs <blockscout-container>"
|
|
echo ""
|
|
fi
|
|
|
|
# Step 7: Restart services
|
|
echo "=== Step 7: Restarting Services ==="
|
|
if [ "$LOCAL_ACCESSIBLE" = false ]; then
|
|
echo "Attempting to restart Blockscout service..."
|
|
pct exec $VMID -- systemctl restart blockscout.service || true
|
|
sleep 5
|
|
|
|
# Test again
|
|
LOCAL_TEST=$(pct exec $VMID -- curl -s -o /dev/null -w '%{http_code}' --connect-timeout 5 http://127.0.0.1:$BLOCKSCOUT_PORT/api/v2/stats 2>/dev/null || echo "000")
|
|
if [ "$LOCAL_TEST" = "200" ]; then
|
|
echo "✅ Blockscout API now responding after restart (HTTP $LOCAL_TEST)"
|
|
LOCAL_ACCESSIBLE=true
|
|
else
|
|
echo "❌ Blockscout API still not responding (HTTP $LOCAL_TEST)"
|
|
fi
|
|
fi
|
|
|
|
# Restart nginx
|
|
echo "Restarting nginx..."
|
|
pct exec $VMID -- systemctl restart nginx || true
|
|
sleep 2
|
|
echo "✅ Nginx restarted"
|
|
echo ""
|
|
|
|
# Step 8: Test external API
|
|
echo "=== Step 8: Testing External API ==="
|
|
EXTERNAL_TEST=$(curl -s -o /dev/null -w '%{http_code}' --connect-timeout 5 "https://explorer.d-bis.org/api/v2/stats" 2>/dev/null || echo "000")
|
|
if [ "$EXTERNAL_TEST" = "200" ]; then
|
|
echo "✅ External API is working (HTTP $EXTERNAL_TEST)"
|
|
echo "✅ 502 error is FIXED!"
|
|
elif [ "$EXTERNAL_TEST" = "502" ]; then
|
|
echo "❌ Still getting 502 error"
|
|
echo ""
|
|
if [ "$LOCAL_ACCESSIBLE" = false ]; then
|
|
echo "Root cause: Blockscout not accessible on localhost:$BLOCKSCOUT_PORT"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Check Blockscout service logs"
|
|
echo "2. Verify docker-compose.yml or service configuration"
|
|
echo "3. Ensure Blockscout is actually running and listening"
|
|
else
|
|
echo "Root cause: nginx cannot proxy to Blockscout"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Check nginx configuration"
|
|
echo "2. Verify proxy_pass is correct"
|
|
echo "3. Check nginx error logs"
|
|
fi
|
|
else
|
|
echo "⚠️ External API returned HTTP $EXTERNAL_TEST"
|
|
fi
|
|
echo ""
|
|
|
|
echo "=========================================="
|
|
echo "Summary"
|
|
echo "=========================================="
|
|
echo "Blockscout Service: $SERVICE_STATUS"
|
|
echo "Port $BLOCKSCOUT_PORT Listening: $([ -n "$PORT_CHECK" ] && echo "Yes" || echo "No")"
|
|
echo "Localhost API: $([ "$LOCAL_ACCESSIBLE" = true ] && echo "✅ Accessible" || echo "❌ Not Accessible")"
|
|
echo "External API: $([ "$EXTERNAL_TEST" = "200" ] && echo "✅ Working" || echo "❌ Not Working ($EXTERNAL_TEST)")"
|
|
echo ""
|
|
|
|
if [ "$EXTERNAL_TEST" != "200" ]; then
|
|
echo "=========================================="
|
|
echo "Troubleshooting Steps"
|
|
echo "=========================================="
|
|
echo ""
|
|
echo "1. Check Blockscout service:"
|
|
echo " pct exec $VMID -- systemctl status blockscout.service"
|
|
echo ""
|
|
echo "2. Check Blockscout logs:"
|
|
echo " pct exec $VMID -- journalctl -u blockscout.service -n 50"
|
|
echo ""
|
|
echo "3. Check docker containers:"
|
|
echo " pct exec $VMID -- docker ps"
|
|
echo ""
|
|
echo "4. Check nginx configuration:"
|
|
echo " pct exec $VMID -- cat /etc/nginx/sites-enabled/blockscout"
|
|
echo ""
|
|
echo "5. Check nginx error logs:"
|
|
echo " pct exec $VMID -- tail -20 /var/log/nginx/error.log"
|
|
echo ""
|
|
fi |