#!/bin/bash # Deploy Logout Debugging System # Run this script to deploy all backend and frontend changes set -e # Exit on error echo "======================================" echo "Deploying Logout Debugging System" echo "======================================" # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Check if we're in the right directory if [ ! -d "backend" ] || [ ! -d "frontend" ]; then echo -e "${RED}Error: Must run from project root directory${NC}" exit 1 fi # Backend deployment echo -e "\n${GREEN}[1/4] Deploying Backend Changes...${NC}" cd backend echo "Running migrations..." python manage.py migrate echo "Checking for migration errors..." python manage.py check echo -e "${GREEN}✓ Backend migrations complete${NC}" # Frontend build echo -e "\n${GREEN}[2/4] Building Frontend...${NC}" cd ../frontend echo "Installing dependencies..." npm install --silent echo "Building production bundle..." npm run build echo -e "${GREEN}✓ Frontend build complete${NC}" # Restart services echo -e "\n${GREEN}[3/4] Restarting Services...${NC}" if command -v docker-compose &> /dev/null; then echo "Restarting Docker containers..." docker-compose restart backend frontend echo -e "${GREEN}✓ Docker services restarted${NC}" elif systemctl is-active --quiet gunicorn; then echo "Restarting systemd services..." sudo systemctl restart gunicorn sudo systemctl restart celery echo -e "${GREEN}✓ Systemd services restarted${NC}" else echo -e "${YELLOW}Warning: Could not detect service manager${NC}" echo "Please restart your backend and frontend services manually" fi # Verification echo -e "\n${GREEN}[4/4] Verifying Deployment...${NC}" echo "Checking backend API..." BACKEND_URL="${BACKEND_URL:-http://localhost:8000}" if curl -s "${BACKEND_URL}/v1/auth/logout-event/" -X POST -H "Content-Type: application/json" -d '{}' > /dev/null; then echo -e "${GREEN}✓ Backend logout-event endpoint responding${NC}" else echo -e "${YELLOW}⚠ Backend endpoint check failed (may need authentication)${NC}" fi echo "Checking frontend build..." if [ -f "frontend/dist/index.html" ]; then echo -e "${GREEN}✓ Frontend dist/index.html exists${NC}" else echo -e "${RED}✗ Frontend build may have failed${NC}" fi # Final instructions echo -e "\n${GREEN}======================================" echo "✓ Deployment Complete!" echo "======================================${NC}" echo -e "\n${YELLOW}Next Steps:${NC}" echo "1. Open browser DevTools (F12)" echo "2. Go to Console tab" echo "3. Look for: '[TokenMonitor] Starting token expiry monitoring...'" echo "4. Login with 'Remember me' checked" echo "5. Wait 25+ minutes to capture logout event" echo "" echo "Debug Panel: Press Ctrl+Shift+D to open" echo "Full Guide: See LOGOUT-DEBUGGING-DEPLOYMENT.md" echo "" echo -e "${YELLOW}Monitor console logs every 30 seconds for token status${NC}" exit 0