fix(backend): use background task for startup to avoid blocking server

Change program.startup() to run via asyncio.create_task() so uvicorn
accepts connections immediately while downloader check runs in background.
Also add .claude/ project settings.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
EstrellaXD
2026-01-23 18:00:06 +01:00
parent 3edddfec09
commit 0408ecdd61
2 changed files with 89 additions and 1 deletions

View File

@@ -0,0 +1,87 @@
{
"permissions": {
"allow": [
"Bash(git -C /Users/estrella/Developer/AutoBangumi/Auto_Bangumi log --oneline -10)",
"Bash(git checkout:*)",
"Bash(python -m pytest:*)",
"Bash(python:*)",
"Bash(uv init:*)",
"Bash(uv sync:*)",
"Bash(uv run pytest:*)",
"Skill(feature-dev:feature-dev)",
"Bash(uv pip install:*)",
"Bash(uv run python:*)",
"Bash(curl:*)",
"Bash(pkill:*)",
"Bash(uv pip show:*)",
"Bash(uv pip list:*)",
"Bash(uv lock:*)",
"Bash(lsof:*)",
"Bash(kill:*)",
"Bash(VITE_API_URL=http://localhost:18080 pnpm dev:*)",
"Bash(pnpm dev:*)",
"Bash(pnpm add:*)",
"Bash(git add:*)",
"Bash(git commit:*)",
"Skill(planning-with-files)",
"Bash(../.venv/bin/python -m pytest test/test_database.py -v)",
"Bash(.venv/bin/python:*)",
"Bash(ruff check:*)",
"Bash(ls:*)",
"Bash(/Users/estrella/Developer/AutoBangumi/Auto_Bangumi/backend/.venv/bin/python:*)",
"Bash(uv run ruff check:*)",
"Bash(git rm:*)",
"Bash(git push:*)",
"Bash(gh pr create:*)",
"Bash(gh pr checks:*)",
"Bash(gh run view:*)",
"Bash(git ls-tree:*)",
"Bash(while read f)",
"Bash(do git show \"HEAD:$f\")",
"Bash(done)",
"Bash(git reset:*)",
"Skill(ui-ux-pro-max)",
"Bash(tree:*)",
"Bash(git stash:*)",
"Bash(python3:*)",
"Bash(pnpm build:*)",
"Bash(pnpm install:*)",
"Bash(uv venv:*)",
"Bash(../.venv/bin/python:*)",
"Bash(xargs:*)",
"Skill(agent-browser)",
"Bash(agent-browser open:*)",
"Bash(agent-browser screenshot:*)",
"Bash(agent-browser snapshot:*)",
"Bash(agent-browser eval \"JSON.stringify\\(window.__consoleErrors || ''no errors captured''\\)\")",
"Bash(agent-browser eval:*)",
"Bash(agent-browser close:*)",
"Bash(agent-browser reload:*)",
"Bash(agent-browser fill:*)",
"Bash(agent-browser click:*)",
"Skill(commit-commands:commit)",
"Bash(gh api:*)",
"Bash(git fetch:*)",
"Bash(git rebase:*)",
"Bash(grep:*)",
"Bash(git merge:*)",
"Bash(agent-browser scroll:*)",
"Bash(agent-browser find text \"Passkey Settings\" click)",
"Bash(agent-browser find:*)",
"Bash(agent-browser find text \"添加\" click)",
"Bash(npx vue-tsc:*)",
"Bash(npx vite build:*)",
"WebSearch",
"WebFetch(domain:bangumi.github.io)",
"WebFetch(domain:raw.githubusercontent.com)",
"WebFetch(domain:api.bgm.tv)",
"Bash(__NEW_LINE_e2219f405dac932c__ echo \"\")",
"Bash(__NEW_LINE_7c1bb4605ef4ad2a__ echo \"\")",
"Bash(source ../.venv/bin/activate)",
"Bash(source:*)",
"Bash(npx vite:*)",
"Bash(agent-browser press:*)",
"Bash(agent-browser get:*)"
]
}
}

View File

@@ -1,3 +1,4 @@
import asyncio
import logging
import os
import signal
@@ -19,7 +20,7 @@ router = APIRouter(tags=["program"])
@router.on_event("startup")
async def startup():
await program.startup()
asyncio.create_task(program.startup())
@router.on_event("shutdown")