-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
32 lines (26 loc) · 976 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import uvicorn
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
import similar_product.product_proc
from db.mysql import get_db
from modules.sys_task import get_tasks
from router.scheduler import router_task, scheduler, init_job
from router.user_router import router
from router.yph_shop_router import router_yph
from similar_product.product_proc import process_product
from utils import get_function_from_string
from apscheduler.triggers.interval import IntervalTrigger
import multiprocessing
# 应用
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
app.include_router(router)
app.include_router(router_yph)
app.include_router(router_task)
@app.on_event("startup")
async def on_startup():
await init_job()
# 通过多线程处理
multiprocessing.Process(target=similar_product.product_proc.process_product())
if __name__ == "__main__":
uvicorn.run(app="main:app", host="127.0.0.1", port=8000)