Enhanced: Comprehensive production debugging and Nginx proxy support

Debugging Tools:
- Added /debug endpoint to verify deployment and test distribution functionality
- Added browser console test function: testDistributionChart()
- Enhanced SocketIO settings with better transport priorities
- Added comprehensive error tracking and status reporting

Nginx Configuration:
- Created NGINX_CONFIG.md with complete proxy setup guide
- Improved WebSocket transport settings and timeouts
- Better ping/pong settings for connection stability

Production Compatibility:
- Optimized SocketIO for proxy environments
- Enhanced fallback mechanisms
- Production-ready logging and error handling

This should resolve proxy-related issues and provide clear diagnostic tools.
This commit is contained in:
2025-08-24 18:53:09 +00:00
parent 6f94b1bd04
commit 97e9e18ee5
4 changed files with 211 additions and 3 deletions

View File

@@ -101,6 +101,59 @@ def results(simulation_id):
title=f"Results - Simulation {simulation_id[:8]}")
@main_bp.route('/debug')
def debug_info():
"""
Debug endpoint to verify deployment and test functionality.
Returns:
JSON response with debug information
"""
import os
from datetime import datetime
from app.models.economic_model import EconomicSimulation, SimulationParameters
# Test distribution functionality
test_params = SimulationParameters(
r_rate=0.05,
g_rate=0.03,
initial_capital=1000,
initial_consumption=1000,
num_agents=10,
iterations=5
)
test_sim = EconomicSimulation(test_params)
# Run a few steps
for _ in range(5):
test_sim.step()
# Get distribution data
labels, counts = test_sim.get_wealth_histogram(5)
debug_data = {
'timestamp': datetime.now().isoformat(),
'environment': os.getenv('FLASK_ENV', 'unknown'),
'config': os.getenv('FLASK_CONFIG', 'unknown'),
'python_version': os.sys.version,
'distribution_test': {
'labels': labels,
'counts': counts,
'total_agents': len(test_sim.agents),
'snapshots': len(test_sim.snapshots)
},
'fixes_deployed': {
'fallback_polling': True,
'enhanced_socketio': True,
'production_debug': True,
'environment_fix': True
},
'version_info': 'v2.1-proxy-fixes'
}
return jsonify(debug_data)
@main_bp.route('/health')
def health_check():
"""