Rename the package roledesk to app
The boilerplate's rule: the deploy kit's Dockerfile, the APP_CONFIG, APP_PASSWORD and APP_DATA variables and its commands all assume a package called app, so a project renames its display title and nothing else. The console script is `app`, and the launch entry runs `uv run app serve --port 8790`. The domain noun stays `role`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
248ea1636d
commit
7a63311714
32 files changed
+102
-98
No files matched your search
@@ -0,0 +1,44 @@
|
||||
"""The application factory: the queue's routes and socket from
|
||||
`pipeline.web.connect`, roledesk's own JSON API, and the one page."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
from pipeline import Jobs
|
||||
from pipeline.web import connect
|
||||
from app import config as config_mod
|
||||
from app import jobs
|
||||
from app.storage import Store
|
||||
from app.web.api import router as api_router
|
||||
from app.web.pages import router as pages_router
|
||||
|
||||
WEB = Path(__file__).resolve().parent
|
||||
|
||||
|
||||
def create_app(config_path: str | None = None) -> FastAPI:
|
||||
config = config_mod.load(config_path)
|
||||
# `Store` first, so the file is at the current schema before the queue
|
||||
# adds its own table to it.
|
||||
store = Store(config.database)
|
||||
jobs.seed_agents(config, store)
|
||||
app = FastAPI(title="roledesk", docs_url="/api/docs")
|
||||
connect(app, Jobs(config.database), config, store,
|
||||
workers=config.workers.model_dump(),
|
||||
bootstrap=jobs.BOOTSTRAP, bootstrap_arg=config.path or "")
|
||||
app.state.config = config
|
||||
app.state.store = store
|
||||
app.include_router(api_router)
|
||||
app.include_router(pages_router)
|
||||
app.mount("/static", StaticFiles(directory=WEB / "static"), name="static")
|
||||
return app
|
||||
|
||||
|
||||
def serve(host: str, port: int, config_path: str | None) -> int:
|
||||
import uvicorn
|
||||
|
||||
uvicorn.run(create_app(config_path), host=host, port=port)
|
||||
return 0
|
||||
Reference in new issue
Block a user