do something when fastapi start

This commit is contained in:
qiaofeng1227 2023-08-02 10:58:30 +08:00
parent 229d1eed13
commit 473efe528c
2 changed files with 5 additions and 1 deletions

View file

@ -11,7 +11,7 @@ COPY static ./static
COPY requirements.txt main.py database.sqlite ./
RUN apt update
# Install supervisord
# Install supervisords
RUN apt install -y supervisor
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY config/cmd.sh /cmd.sh

View file

@ -13,6 +13,10 @@ from fastapi.openapi.docs import (
myLogger.info_logger("Start server...")
app = FastAPI(docs_url=None, redoc_url=None, openapi_url="/")
@app.on_event("startup")
async def startup_event():
print("应用程序已启动!")
def get_app():
origins = [
"http://localhost",