#!/bin/bash
# Service Status Checker
# Check status of background services without watch patterns

echo "=== Service Status ==="
echo ""

# Check trading bot
if pgrep -f "bitcoin-trading-bot.*trading_bot" > /dev/null; then
    PID=$(pgrep -f "bitcoin-trading-bot.*trading_bot")
    UPTIME=$(ps -o etime= -p $PID 2>/dev/null)
    echo "✓ Bitcoin Trading Bot: RUNNING (PID: $PID, Uptime: $UPTIME)"
else
    echo "✗ Bitcoin Trading Bot: STOPPED"
fi

# Check dashboard
if pgrep -f "dashboard.*app.py" > /dev/null; then
    PID=$(pgrep -f "dashboard.*app.py")
    UPTIME=$(ps -o etime= -p $PID 2>/dev/null)
    echo "✓ Dashboard: RUNNING (PID: $PID, Uptime: $UPTIME)"
else
    echo "✗ Dashboard: STOPPED"
fi

# Check nostr notifier (if exists)
if pgrep -f "nostr.*notifier" > /dev/null; then
    PID=$(pgrep -f "nostr.*notifier")
    UPTIME=$(ps -o etime= -p $PID 2>/dev/null)
    echo "✓ Nostr Notifier: RUNNING (PID: $PID, Uptime: $UPTIME)"
else
    echo "○ Nostr Notifier: NOT CONFIGURED"
fi

# Check hermes gateway
if pgrep -f "hermes_cli.main gateway" > /dev/null; then
    PID=$(pgrep -f "hermes_cli.main gateway")
    UPTIME=$(ps -o etime= -p $PID 2>/dev/null)
    echo "✓ Hermes Gateway: RUNNING (PID: $PID, Uptime: $UPTIME)"
else
    echo "✗ Hermes Gateway: STOPPED"
fi

echo ""
echo "=== Memory Usage ==="
ps -o pid,rss,comm -f | grep -E "python.*trading|python.*dashboard|python.*hermes" | head -5
