Return to Flask
This commit is contained in:
@@ -36,5 +36,5 @@ EXPOSE 5000
|
|||||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||||
CMD python -c "import requests; requests.get('http://localhost:5000/health', timeout=2)" || exit 1
|
CMD python -c "import requests; requests.get('http://localhost:5000/health', timeout=2)" || exit 1
|
||||||
|
|
||||||
# Run the application with Gunicorn using gevent workers for SocketIO compatibility
|
# Run the application with Flask's built-in server
|
||||||
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "4", "--worker-class", "gevent", "--worker-connections", "1000", "--timeout", "30", "wsgi:app"]
|
CMD ["python", "run.py"]
|
@@ -1,9 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
markov-economics:
|
markov-economics:
|
||||||
build: .
|
build: .
|
||||||
# Remove direct port mapping since Caddy will handle external access
|
ports:
|
||||||
# ports:
|
- "5000:5000"
|
||||||
# - "5000:5000"
|
|
||||||
environment:
|
environment:
|
||||||
- FLASK_ENV=production
|
- FLASK_ENV=production
|
||||||
- FLASK_APP=run.py
|
- FLASK_APP=run.py
|
||||||
|
10
run.py
10
run.py
@@ -15,11 +15,5 @@ if __name__ == '__main__':
|
|||||||
debug_mode = config_name == 'development'
|
debug_mode = config_name == 'development'
|
||||||
port = int(os.getenv('PORT', 5000)) # Use PORT env var or default to 5000
|
port = int(os.getenv('PORT', 5000)) # Use PORT env var or default to 5000
|
||||||
|
|
||||||
# For production deployment with Gunicorn, SocketIO will be handled by Gunicorn
|
# Run with SocketIO's built-in server for both development and production
|
||||||
# For development, we use SocketIO's built-in server
|
socketio.run(app, debug=debug_mode, host='0.0.0.0', port=port, allow_unsafe_werkzeug=True)
|
||||||
if config_name == 'production':
|
|
||||||
# In production, Gunicorn will handle the server
|
|
||||||
# This is just a fallback
|
|
||||||
socketio.run(app, debug=False, host='0.0.0.0', port=port, allow_unsafe_werkzeug=True)
|
|
||||||
else:
|
|
||||||
socketio.run(app, debug=debug_mode, host='0.0.0.0', port=port)
|
|
Reference in New Issue
Block a user