chore: Second cleanup wave - organize root directory

- Archive: 85 agent .txt files → docs/archive/agents/legacy_txt/
- Scripts: Move 110 shell scripts → scripts/ (keep deploy.sh in root)
- Models: Move 18 .safetensors → ml/models/checkpoints/training_artifacts/
- Delete: 34 directories (~33GB freed) - target/, coverage_*, test artifacts
- Build: Clean 14 build artifacts (.rlib, .o, .pid, binaries)
- Tests: Move 14 .rs files → tests/standalone/
- SQL: Move 5 files → sql/ (keep init-db*.sql for Docker)
- Wave 153: Archive to docs/archive/historical/wave153/
- Docs: Archive 9 markdown files to wave_d/reports/ and historical/

Total impact: ~34GB freed (both waves), root directory cleaned from 583 to ~40 essential files
Directory count reduced from 65 to 31 (52% reduction)
All historical data preserved in organized archive structure
This commit is contained in:
jgrusewski
2025-10-30 01:26:02 +01:00
parent 46fab7215c
commit 8d89fe80ff
424 changed files with 859 additions and 33479 deletions

86
scripts/stop.sh Executable file
View File

@@ -0,0 +1,86 @@
#!/bin/bash
# Foxhunt HFT Trading System - Complete System Shutdown
# Stops 3 standalone services + databases as per TLI_PLAN.md architecture
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
echo -e "${RED}🛑 Stopping Foxhunt HFT Trading System${NC}"
echo "================================================="
echo "Shutting down: 3 Services + Docker Databases"
# Step 1: Stop services by PID files if they exist
echo -e "${BLUE}🔌 Stopping standalone services...${NC}"
if [ -f .trading_service.pid ]; then
TRADING_PID=$(cat .trading_service.pid)
echo "📈 Stopping Trading Service (PID: $TRADING_PID)"
kill $TRADING_PID 2>/dev/null || true
rm -f .trading_service.pid
fi
if [ -f .backtesting_service.pid ]; then
BACKTEST_PID=$(cat .backtesting_service.pid)
echo "🔄 Stopping Backtesting Service (PID: $BACKTEST_PID)"
kill $BACKTEST_PID 2>/dev/null || true
rm -f .backtesting_service.pid
fi
if [ -f .ml_training_service.pid ]; then
ML_PID=$(cat .ml_training_service.pid)
echo "🧠 Stopping ML Training Service (PID: $ML_PID)"
kill $ML_PID 2>/dev/null || true
rm -f .ml_training_service.pid
fi
# Step 2: Fallback - kill by process name
echo -e "${YELLOW}🧹 Cleaning up any remaining service processes...${NC}"
pkill -f "trading_service" || true
pkill -f "backtesting_service" || true
pkill -f "ml_training_service" || true
# Give processes time to shut down gracefully
sleep 2
# Step 3: Stop Docker databases
echo -e "${BLUE}🗄️ Stopping Docker databases...${NC}"
# Use docker compose (newer) or docker-compose (older)
DOCKER_COMPOSE_CMD="docker compose"
if ! command -v docker >/dev/null 2>&1 || ! docker compose version >/dev/null 2>&1; then
DOCKER_COMPOSE_CMD="docker-compose"
fi
if command -v docker >/dev/null 2>&1; then
echo "Stopping databases with $DOCKER_COMPOSE_CMD..."
$DOCKER_COMPOSE_CMD down
# Optional: Remove volumes (uncomment to completely clean databases)
# echo -e "${YELLOW}⚠️ Removing database volumes (data will be lost)...${NC}"
# docker volume rm foxhunt_postgres_data foxhunt_influxdb_data foxhunt_redis_data 2>/dev/null || true
else
echo -e "${YELLOW}⚠️ Docker not found, skipping database shutdown${NC}"
fi
# Step 4: Clean up any remaining ports
echo -e "${YELLOW}🔍 Checking for services still using ports...${NC}"
for port in 50051 50052 50053; do
PID=$(lsof -ti :$port 2>/dev/null || true)
if [ ! -z "$PID" ]; then
echo "⚠️ Force killing process $PID on port $port"
kill -9 $PID 2>/dev/null || true
fi
done
echo -e "${GREEN}✅ All services and databases stopped${NC}"
echo ""
echo "System components stopped:"
echo "├── Trading Service (port 50051)"
echo "├── Backtesting Service (port 50052)"
echo "├── ML Training Service (port 50053)"
echo "└── Databases (PostgreSQL, InfluxDB, Redis)"
echo ""
echo -e "${GREEN}System shutdown complete${NC}"