diff --git a/Dockerfile b/Dockerfile index 0ed3cac..1ebc186 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,4 +12,4 @@ COPY . . EXPOSE 5000 # 确保模块名和 Flask 实例名正确(默认是 app:app) -CMD ["waitress-serve", "--host=0.0.0.0", "--port=5000", "app:app"] \ No newline at end of file +CMD ["gunicorn", "-w", "2", "-k", "gthread", "--threads", "4", "-b", "0.0.0.0:5000", "app:app"] diff --git a/__pycache__/app.cpython-311.pyc b/__pycache__/app.cpython-311.pyc new file mode 100644 index 0000000..7020e05 Binary files /dev/null and b/__pycache__/app.cpython-311.pyc differ diff --git a/test_my_mode.py b/app.py similarity index 96% rename from test_my_mode.py rename to app.py index 44bc30d..768171d 100644 --- a/test_my_mode.py +++ b/app.py @@ -15,7 +15,7 @@ SAVE_DIR = "./cate1" # 模型路径 LABEL_ENCODER_PATH = "cate1/label_encoder.pkl" # 标签映射器路径 app = Flask(__name__) - +app.config['JSON_AS_ASCII'] = False # 全局变量锁 model_lock = threading.Lock() @@ -124,6 +124,7 @@ def health_check(): if __name__ == '__main__': - # 生产环境建议使用: - # gunicorn -w 4 -b 0.0.0.0:5000 app:app --timeout 120 - app.run(host='0.0.0.0', port=5002, threaded=True) \ No newline at end of file + app.run(host='0.0.0.0', port=5000, threaded=True) +else: + application = app # 兼容 WSGI 标准(如 Gunicorn) + diff --git a/requirements.txt b/requirements.txt index 20b763a..68988fd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # 基础依赖 Flask==3.1.0 -waitress==3.0.2 +gunicorn==20.0.4 transformers==4.26.0 # 数据处理