diff --git a/flask/Dockerfile b/flask/Dockerfile index e8b74cc..f63e470 100644 --- a/flask/Dockerfile +++ b/flask/Dockerfile @@ -19,6 +19,6 @@ USER flaskuser # CMD python application.py run --debug --host 0.0.0.0 # without Flask-SocketIO -# CMD gunicorn --access-logfile '-' --workers 3 --threads 4 --bind 0.0.0.0:5000 application:application -# with Flask-SocketIO, gunicorn does not support sticky sessions, workers must be 1. eventlet takes care of multi-threading, threads must be 1 -CMD gunicorn --access-logfile '-' --log-level 'debug' --worker-class eventlet --workers 1 --bind 0.0.0.0:5000 application:application +# CMD gunicorn --access-logfile '-' -w 3 -t 4 -b 0.0.0.0:5000 application:application +# with Flask-SocketIO, gunicorn does not support sticky sessions, workers must be 1. gevent takes care of multi-threading, threads must be 1 +CMD gunicorn --access-logfile '-' --log-level 'debug' -k gevent -w 1 -b 0.0.0.0:5000 application:application diff --git a/flask/app/__init__.py b/flask/app/__init__.py index 64facd3..3722c7c 100644 --- a/flask/app/__init__.py +++ b/flask/app/__init__.py @@ -15,7 +15,7 @@ def create_app(): r"/*": {"origins": []} }) - app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://{username}:{password}@{host}:{port}/{database}'.format( + app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg://{username}:{password}@{host}:{port}/{database}'.format( username=os.environ['RDS_USERNAME'], password=os.environ['RDS_PASSWORD'], host=os.environ['RDS_HOSTNAME'], diff --git a/flask/application.py b/flask/application.py index 8d1d99b..2bb733c 100644 --- a/flask/application.py +++ b/flask/application.py @@ -1,7 +1,5 @@ -import eventlet - -# perform monkey patching for eventlet -eventlet.monkey_patch() +from gevent import monkey +monkey.patch_all() from flask import Flask, jsonify from app import create_app, db, socketio diff --git a/flask/requirements.txt b/flask/requirements.txt index c8b36a2..a41cf96 100644 --- a/flask/requirements.txt +++ b/flask/requirements.txt @@ -1,28 +1,32 @@ async-timeout==4.0.3 bidict==0.22.1 +blinker==1.7.0 click==8.1.7 -dnspython==2.4.2 -eventlet==0.34.2 -Flask==2.2.3 -Flask-Cors==3.0.10 +dnspython==2.5.0 +Flask==3.0.1 +Flask-Cors==4.0.0 Flask-SocketIO==5.3.6 -Flask-SQLAlchemy==3.0.3 -greenlet==2.0.2 +Flask-SQLAlchemy==3.1.1 +gevent==23.9.1 +greenlet==3.0.3 gunicorn==21.2.0 h11==0.14.0 importlib-metadata==7.0.1 itsdangerous==2.1.2 -Jinja2==3.1.2 -MarkupSafe==2.1.3 +Jinja2==3.1.3 +MarkupSafe==2.1.4 packaging==23.2 -psycopg2-binary==2.9.6 +psycopg==3.1.17 +psycopg-binary==3.1.17 python-engineio==4.8.2 python-socketio==5.11.0 redis==5.0.1 simple-websocket==1.0.0 six==1.16.0 -SQLAlchemy==2.0.9 +SQLAlchemy==2.0.25 typing_extensions==4.9.0 -Werkzeug==2.2.3 +Werkzeug==3.0.1 wsproto==1.2.0 -zipp==3.15.0 \ No newline at end of file +zipp==3.17.0 +zope.event==5.0 +zope.interface==6.1