Restructured project for V2 refactor: **Structure Changes:** - Moved all V1 code to orig/ folder (preserved with git mv) - Created docs/planning/ directory - Added orig/README_V1.md explaining V1 preservation **Planning Documents:** - 00_V2_MASTER_PLAN.md: Complete architecture overview - Executive summary of critical V1 issues - High-level component architecture diagrams - 5-phase implementation roadmap - Success metrics and risk mitigation - 07_TASK_BREAKDOWN.md: Atomic task breakdown - 99+ hours of detailed tasks - Every task < 2 hours (atomic) - Clear dependencies and success criteria - Organized by implementation phase **V2 Key Improvements:** - Per-exchange parsers (factory pattern) - Multi-layer strict validation - Multi-index pool cache - Background validation pipeline - Comprehensive observability **Critical Issues Addressed:** - Zero address tokens (strict validation + cache enrichment) - Parsing accuracy (protocol-specific parsers) - No audit trail (background validation channel) - Inefficient lookups (multi-index cache) - Stats disconnection (event-driven metrics) Next Steps: 1. Review planning documents 2. Begin Phase 1: Foundation (P1-001 through P1-010) 3. Implement parsers in Phase 2 4. Build cache system in Phase 3 5. Add validation pipeline in Phase 4 6. Migrate and test in Phase 5 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
97 lines
2.6 KiB
Bash
Executable File
97 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Git post-merge hook
|
|
# This hook runs after 'git pull' or 'git merge'
|
|
# Automatically rebuilds and restarts the MEV bot
|
|
|
|
set -e
|
|
|
|
HOOK_DIR=$(dirname "$0")
|
|
PROJECT_DIR=$(cd "$HOOK_DIR/../.." && pwd)
|
|
|
|
echo "========================================="
|
|
echo "Post-Merge Hook: Auto-Rebuild & Restart"
|
|
echo "========================================="
|
|
echo "Project: $PROJECT_DIR"
|
|
echo ""
|
|
|
|
# Color codes
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Change to project directory
|
|
cd "$PROJECT_DIR"
|
|
|
|
# Check if Docker Compose is available
|
|
if ! command -v docker &> /dev/null; then
|
|
echo -e "${RED}Error: Docker not found${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
# Log the update
|
|
LOG_FILE="$PROJECT_DIR/logs/auto-update.log"
|
|
mkdir -p "$PROJECT_DIR/logs"
|
|
echo "[$(date)] Post-merge hook triggered" >> "$LOG_FILE"
|
|
|
|
# Get the latest commit info
|
|
LATEST_COMMIT=$(git log -1 --pretty=format:"%h - %s")
|
|
echo -e "${YELLOW}Latest commit: $LATEST_COMMIT${NC}"
|
|
echo "[$(date)] Latest commit: $LATEST_COMMIT" >> "$LOG_FILE"
|
|
|
|
# Rebuild the Docker image
|
|
echo ""
|
|
echo -e "${YELLOW}Rebuilding Docker image...${NC}"
|
|
if docker compose build --no-cache >> "$LOG_FILE" 2>&1; then
|
|
echo -e "${GREEN}✓ Docker image rebuilt${NC}"
|
|
echo "[$(date)] Docker image rebuilt successfully" >> "$LOG_FILE"
|
|
else
|
|
echo -e "${RED}✗ Docker build failed - check logs${NC}"
|
|
echo "[$(date)] ERROR: Docker build failed" >> "$LOG_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# Restart the container
|
|
echo ""
|
|
echo -e "${YELLOW}Restarting container...${NC}"
|
|
if docker compose up -d >> "$LOG_FILE" 2>&1; then
|
|
echo -e "${GREEN}✓ Container restarted${NC}"
|
|
echo "[$(date)] Container restarted successfully" >> "$LOG_FILE"
|
|
else
|
|
echo -e "${RED}✗ Container restart failed - check logs${NC}"
|
|
echo "[$(date)] ERROR: Container restart failed" >> "$LOG_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# Wait a few seconds for the container to start
|
|
sleep 5
|
|
|
|
# Check container status
|
|
echo ""
|
|
echo -e "${YELLOW}Container status:${NC}"
|
|
docker compose ps
|
|
|
|
# Show recent logs
|
|
echo ""
|
|
echo -e "${YELLOW}Recent logs:${NC}"
|
|
docker compose logs --tail=20 mev-bot
|
|
|
|
echo ""
|
|
echo -e "${GREEN}========================================="
|
|
echo "Auto-update complete!"
|
|
echo "=========================================${NC}"
|
|
echo ""
|
|
echo "View full logs: tail -f $LOG_FILE"
|
|
echo "View container logs: docker compose logs -f mev-bot"
|
|
echo ""
|
|
|
|
# Send notification if curl is available (optional)
|
|
if command -v curl &> /dev/null && [ -n "$WEBHOOK_URL" ]; then
|
|
curl -X POST "$WEBHOOK_URL" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"text\":\"MEV Bot updated to: $LATEST_COMMIT\"}" \
|
|
>> "$LOG_FILE" 2>&1 || true
|
|
fi
|
|
|
|
exit 0
|