Fix: Wealth Distribution Histogram behind Nginx proxy
Production Environment Fixes: - Enhanced SocketIO configuration for proxy compatibility - Added fallback polling mechanism when WebSocket fails - Fixed environment configuration (FLASK_ENV vs FLASK_CONFIG) - Added production-friendly debug logging for distribution chart - Improved connection status monitoring and error handling Proxy-Specific Improvements: - Enhanced CORS and transport settings for SocketIO - Fallback to HTTP polling when WebSocket connections fail - Better error handling and retry mechanisms - Debug logging that works in production mode This should resolve the wealth distribution histogram issue when running behind Nginx proxy in Docker containers.
This commit is contained in:
7
run.py
7
run.py
@@ -7,14 +7,15 @@ Demonstrates how capitalism "eats the world" using Markov chains.
|
||||
import os
|
||||
from app import create_app, socketio
|
||||
|
||||
config_name = os.getenv('FLASK_CONFIG', 'development')
|
||||
# Use FLASK_ENV if set, otherwise default to development
|
||||
config_name = os.getenv('FLASK_ENV', 'development')
|
||||
app = create_app(config_name)
|
||||
|
||||
if __name__ == '__main__':
|
||||
debug_mode = os.getenv('FLASK_ENV', 'development') == 'development'
|
||||
debug_mode = config_name == 'development'
|
||||
|
||||
# For production deployment, allow unsafe werkzeug or use a proper WSGI server
|
||||
if os.getenv('FLASK_ENV') == 'production':
|
||||
if config_name == 'production':
|
||||
socketio.run(app, debug=False, host='0.0.0.0', port=5000, allow_unsafe_werkzeug=True)
|
||||
else:
|
||||
socketio.run(app, debug=debug_mode, host='0.0.0.0', port=5000)
|
Reference in New Issue
Block a user