From d8a3c1717dab6ee45475e333e9b044a69122e669 Mon Sep 17 00:00:00 2001 From: biek12 <1274180586@qq.com> Date: Thu, 28 Dec 2023 22:15:32 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E5=A2=9E=E5=8A=A0dockerfile=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E9=85=8D=E7=BD=AE=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 7 +++++++ start.sh | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7a1bd2d..ef6fdee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,9 +9,16 @@ COPY . /app # 设置环境变量 ENV PYTHONUNBUFFERED=1 +# 设置工作进程数 +ENV PROCESS_WORKERS=1 +# 设置工作线程数 +ENV PROCESS_THREADS=2 RUN chmod +x /app/start.sh +# 设置 pip 源为清华大学镜像 +RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple + # 安装任何所需的依赖项 RUN pip install --no-cache-dir flask gunicorn requests Pillow flask-cors tiktoken diff --git a/start.sh b/start.sh index 7492e73..f5e4495 100755 --- a/start.sh +++ b/start.sh @@ -3,8 +3,18 @@ # 记录当前日期和时间 NOW=$(date +"%Y-%m-%d-%H-%M") + +# 如未设置,填充默认值 +if [ -z "$PROCESS_WORKERS" ]; then + export PROCESS_WORKERS=1 +fi + +if [ -z "$PROCESS_THREADS" ]; then + export PROCESS_THREADS=2 +fi + # 启动 Gunicorn 并使用 tee 命令同时输出日志到文件和控制台 -exec gunicorn -w 2 --threads 2 --bind 0.0.0.0:33333 main:app --access-logfile - --error-logfile - +exec gunicorn -w ${PROCESS_WORKERS} --threads ${PROCESS_THREADS} --bind 0.0.0.0:33333 main:app --access-logfile - --error-logfile - # python3 ./main.py