diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index d00a156..91601e8 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -432,21 +432,74 @@ jobs: chmod -R 755 /var/www/mnemo_cards echo "✅ Permissions fixed" + # Pre-reload diagnostics + echo "🔍 Pre-reload diagnostics..." + echo "📊 Current nginx status:" + sudo systemctl status nginx --no-pager || true + + echo "🌐 Testing upstream connectivity before reload:" + if nc -z 127.0.0.1 3000 2>/dev/null; then + echo "✅ Forgejo (port 3000): reachable" + else + echo "❌ Forgejo (port 3000): NOT reachable before reload!" + fi + + if nc -z 127.0.0.1 8081 2>/dev/null; then + echo "✅ Backend (port 8081): reachable" + else + echo "❌ Backend (port 8081): NOT reachable before reload!" + fi + + echo "🌐 Testing site accessibility before reload:" + for site in "https://mnemo-cards.online/" "https://code.mnemo-cards.online/" "https://vscode.mnemo-cards.online/"; do + if curl -I --max-time 5 "$site" 2>/dev/null | grep -q "200\|301\|302"; then + echo "✅ $site accessible before reload" + else + echo "⚠️ $site not accessible before reload" + curl -I --max-time 5 "$site" || true + fi + done + echo "🔄 Reloading nginx to serve new web app..." - if sudo nginx -t 2>/dev/null; then + echo "📋 Current nginx configuration test:" + if sudo nginx -t 2>&1; then + echo "✅ nginx configuration is valid" + echo "🚀 Executing nginx reload..." sudo systemctl reload nginx - echo "✅ nginx reloaded successfully" + RELOAD_RESULT=$? + if [ $RELOAD_RESULT -eq 0 ]; then + echo "✅ nginx reloaded successfully" + else + echo "❌ nginx reload failed with exit code $RELOAD_RESULT" + sudo systemctl status nginx --no-pager || true + fi + else + echo "❌ nginx configuration test failed!" + sudo nginx -t || true + exit 1 + fi # Wait for services to stabilize after reload - echo "⏳ Waiting for services to stabilize..." + echo "⏳ Waiting for services to stabilize after reload..." sleep 5 + # Check nginx logs for errors after reload + echo "📋 Checking nginx error logs after reload:" + sudo tail -20 /var/log/nginx/error.log || true + + # Check nginx status again + echo "📊 Nginx status after reload:" + sudo systemctl status nginx --no-pager || true + # Check all services status echo "📊 Checking service statuses after nginx reload..." # Check nginx if sudo systemctl is-active --quiet nginx; then echo "✅ nginx: running" + # Check loaded configuration + echo "📋 Loaded nginx sites:" + ls -la /etc/nginx/sites-enabled/ || true else echo "❌ nginx: not running" sudo systemctl status nginx --no-pager || true @@ -489,6 +542,16 @@ jobs: pkill -f "act" || true sleep 1 + # Check web app files + echo "📁 Checking web app files:" + if [ -f "/var/www/mnemo_cards/index.html" ]; then + echo "✅ index.html exists" + ls -la /var/www/mnemo_cards/ | head -10 || true + else + echo "❌ index.html not found!" + ls -la /var/www/ || true + fi + # Check system resources echo "📊 System resources after cleanup:" free -h || true