Replace APScheduler to Celery asynchronous tasks (#229)

* Replace APScheduler to Celery task

* black format

* Add celery to run the script

* Update celery usage to README

* Update test task

* Add celery rabbitmq broker

* Fix dockerfiles

* Add task interface access authorization

* Update celery deploy run

* Fix dockerfiles

* Fix supervisor conf

* Update celery broker default is redis

* Force the pro env to use rabbitmq

* Update the task interface

* Add celery beat README description

* Update warning text style

* Revoke the default config comment content of the supervisor
This commit is contained in:
Wu Clan
2023-10-27 11:59:46 +08:00
committed by GitHub
parent 81c0d2cc74
commit 275f9e5e93
22 changed files with 330 additions and 316 deletions

26
backend.dockerfile Normal file
View File

@ -0,0 +1,26 @@
FROM python:3.10-slim
WORKDIR /fba
COPY . .
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources \
&& sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list.d/debian.sources
RUN apt-get update \
&& apt-get install -y --no-install-recommends gcc python3-dev \
&& rm -rf /var/lib/apt/lists/*
# 某些包可能存在同步不及时导致安装失败的情况可更改为官方源https://pypi.org/simple
RUN pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple \
&& pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
ENV TZ = Asia/Shanghai
RUN mkdir -p /var/log/fastapi_server
COPY ./deploy/fastapi_server.conf /etc/supervisor/conf.d/
EXPOSE 8001
CMD ["uvicorn", "backend.app.main:app", "--host", "127.0.0.1", "--port", "8000"]