#!/bin/bash
# Start complete real-time order flow system

echo "=========================================="
echo "STARTING REAL-TIME ORDER FLOW SYSTEM"
echo "=========================================="
echo ""

# Start continuous collector
echo "1. Starting continuous WebSocket collector..."
cd /home/ubuntu/.hermes/workspace/projects/ORDER_FLOW_GRAPH/scripts
./start_continuous_collector.sh
echo ""

# Wait for collector to initialize
sleep 5

# Start signal generator
echo "2. Starting real-time signal generator..."
./start_realtime_generator.sh
echo ""

# Check processes
echo "3. Checking processes..."
echo ""

if ps aux | grep -v grep | grep "collect_multi_asset.py" > /dev/null; then
    echo "✓ Collector is running"
else
    echo "✗ Collector failed to start"
fi

if ps aux | grep -v grep | grep "realtime_signal_generator.py" > /dev/null; then
    echo "✓ Signal generator is running"
else
    echo "✗ Signal generator failed to start"
fi

echo ""
echo "=========================================="
echo "SYSTEM STATUS"
echo "=========================================="
echo ""
echo "Collector:  Running (24/7 WebSocket connection)"
echo "Signals:     Updating every 60 seconds"
echo "UI:          http://localhost:8080/realtime.html"
echo ""
echo "Logs:"
echo "  Collector:  tail -f /tmp/order_flow_collector.log"
echo "  Generator:  tail -f /tmp/realtime_signal_generator.log"
echo ""
echo "To stop everything:"
echo "  cd /home/ubuntu/.hermes/workspace/projects/ORDER_FLOW_GRAPH/scripts"
echo "  ./stop_continuous_collector.sh"
echo "  ./stop_realtime_generator.sh"
echo "=========================================="
