OverviewFilesCommitsIssuesDocsReleasesPeers

wirecore / wirecore-relay / status-relay.sh

73 lines · bash ref:
#!/bin/bash

# Wirecore Relay - Status Script
# Shows current status of the relay server

set -e

PID_FILE="/tmp/wirecore-relay.pid"
LOG_FILE="/tmp/wirecore-relay.log"

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "  Wirecore Relay Status"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

# Check PID file
if [ -f "$PID_FILE" ]; then
    PID=$(cat "$PID_FILE")
    if ps -p "$PID" > /dev/null 2>&1; then
        echo "Status: ✅ RUNNING"
        echo "PID: $PID"
        echo ""

        # Show process info
        ps -p "$PID" -o pid,vsz,rss,pcpu,etime,cmd | tail -n +2
        echo ""

        # Show port
        PORT=$(ss -tln | grep :9000 | head -1 || echo "")
        if [ -n "$PORT" ]; then
            echo "Port: ✅ 9000 listening"
        else
            echo "Port: ❌ 9000 not listening"
        fi
        echo ""

        # Test HTTP
        if curl -s -o /dev/null -w "%{http_code}" http://localhost:9000/stats | grep -q "200"; then
            echo "HTTP: ✅ Responding"
            echo ""
            echo "Recent stats:"
            curl -s http://localhost:9000/stats | head -15
        else
            echo "HTTP: ❌ Not responding"
        fi

    else
        echo "Status: ❌ NOT RUNNING (stale PID file)"
        echo "PID file: $PID_FILE"
        rm -f "$PID_FILE"
    fi
else
    echo "Status: ❌ NOT RUNNING"
    echo "No PID file found"
    echo ""

    # Check if running manually
    MANUAL_PID=$(pgrep -f "node.*wirecore-relay" || echo "")
    if [ -n "$MANUAL_PID" ]; then
        echo "⚠️  Found relay running manually (PID: $MANUAL_PID)"
        echo "Not started via start-relay.sh"
    fi
fi

echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Commands:"
echo "  Start:  ./wirecore-relay/start-relay.sh"
echo "  Stop:   ./wirecore-relay/stop-relay.sh"
echo "  Logs:   tail -f $LOG_FILE"
echo ""