mirror of
https://github.com/fastapi-practices/fastapi-best-architecture.git
synced 2026-09-21 21:15:13 +00:00
Update the CLI startup service mode (#718)
This commit is contained in:
+12
-8
@@ -4,11 +4,10 @@ import asyncio
|
||||
import os
|
||||
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Annotated
|
||||
|
||||
import cappa
|
||||
import uvicorn
|
||||
import granian
|
||||
|
||||
from rich.panel import Panel
|
||||
from rich.text import Text
|
||||
@@ -18,6 +17,7 @@ from backend import console, get_version
|
||||
from backend.common.enums import DataBaseType, PrimaryKeyType
|
||||
from backend.common.exception.errors import BaseExceptionMixin
|
||||
from backend.core.conf import settings
|
||||
from backend.core.path_conf import BASE_PATH
|
||||
from backend.database.db import async_db_session
|
||||
from backend.plugin.tools import get_plugin_sql
|
||||
from backend.utils.file_ops import install_git_plugin, install_zip_plugin, parse_sql_script
|
||||
@@ -39,14 +39,18 @@ def run(host: str, port: int, reload: bool, workers: int | None) -> None:
|
||||
)
|
||||
|
||||
console.print(Panel(panel_content, title='fba 服务信息', border_style='purple', padding=(1, 2)))
|
||||
uvicorn.run(
|
||||
app='backend.main:app',
|
||||
host=host,
|
||||
granian.Granian(
|
||||
target='backend.main:app',
|
||||
interface='asgi',
|
||||
address=host,
|
||||
port=port,
|
||||
reload=not reload,
|
||||
reload_excludes=[os.path.abspath('.venv' if Path(Path.cwd() / '.venv').is_dir() else '../.venv')],
|
||||
workers=workers,
|
||||
)
|
||||
reload_ignore_paths=[
|
||||
os.path.join(BASE_PATH.parent / '.venv'),
|
||||
os.path.join(BASE_PATH / 'log'),
|
||||
],
|
||||
workers=workers or 1,
|
||||
).serve()
|
||||
|
||||
|
||||
async def install_plugin(
|
||||
|
||||
Reference in New Issue
Block a user