From 833de4a0c41983b1cb32556b1d34d77f7131e6be Mon Sep 17 00:00:00 2001 From: Stiftung Development Date: Tue, 16 Sep 2025 00:04:03 +0200 Subject: [PATCH] Add production debugging script for future troubleshooting --- debug-production.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 debug-production.sh diff --git a/debug-production.sh b/debug-production.sh new file mode 100644 index 0000000..066e05b --- /dev/null +++ b/debug-production.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# Production Debugging Script for 502 Bad Gateway +# Run this on your production server to diagnose issues + +echo "===================================================================" +echo "🔍 STIFTUNG PRODUCTION DEBUGGING SCRIPT" +echo "===================================================================" +echo "Current time: $(date)" +echo + +echo "📁 Current directory and .env file check:" +pwd +echo "--- .env file exists? ---" +ls -la .env 2>/dev/null && echo "✅ .env file found" || echo "❌ .env file missing" +echo + +echo "🐳 Docker container status:" +docker-compose -f compose.yml ps +echo + +echo "📊 Container resource usage:" +docker stats --no-stream +echo + +echo "📋 Recent container logs (last 50 lines each):" +echo "--- WEB CONTAINER LOGS ---" +docker-compose -f compose.yml logs --tail=50 web +echo +echo "--- DATABASE CONTAINER LOGS ---" +docker-compose -f compose.yml logs --tail=50 db +echo +echo "--- REDIS CONTAINER LOGS ---" +docker-compose -f compose.yml logs --tail=50 redis +echo + +echo "🌐 Network connectivity test:" +echo "--- Can we reach the web container internally? ---" +docker-compose -f compose.yml exec web curl -f http://localhost:8000/admin/ 2>/dev/null && echo "✅ Django responding internally" || echo "❌ Django not responding internally" +echo + +echo "💾 Database connectivity test:" +echo "--- Database connection test ---" +docker-compose -f compose.yml exec web python manage.py check --database default 2>/dev/null && echo "✅ Database connected" || echo "❌ Database connection failed" +echo + +echo "🔧 Django management commands:" +echo "--- Running Django check ---" +docker-compose -f compose.yml exec web python manage.py check +echo + +echo "🚀 Environment variables (sensitive values hidden):" +docker-compose -f compose.yml exec web printenv | grep -E '^(DJANGO_|POSTGRES_|DB_|REDIS_)' | sed 's/=.*/=***HIDDEN***/' +echo + +echo "===================================================================" +echo "🎯 DEBUGGING COMPLETE" +echo "===================================================================" \ No newline at end of file