Update the CLI startup service mode (#718)

This commit is contained in:
Wu Clan
2025-07-10 20:33:50 +08:00
committed by GitHub
parent adee3a2177
commit e84ef04f15
4 changed files with 18 additions and 11 deletions
+12 -8
View File
@@ -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(