major server manager overhaul

This commit is contained in:
2026-01-09 19:24:41 +00:00
parent 6a667d1019
commit c0ac650625
202 changed files with 325323 additions and 6929 deletions
+33 -8
View File
@@ -1,20 +1,39 @@
from fastapi import FastAPI, Depends
import os
import json
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from sqlalchemy.orm import Session
from contextlib import asynccontextmanager
from . import models
from .database import SessionLocal, engine, get_db
from .routers import samba, comics, duplicates, downloader
from .routers import samba, comics, duplicates, downloader, qbittorrent, system, tasks, settings, stash, scheduler as scheduler_router
from .scheduler import start_scheduler, scheduler
models.Base.metadata.create_all(bind=engine)
app = FastAPI()
def reset_stuck_scans():
progress_file = "logs/duplicates_scan.json"
if os.path.exists(progress_file):
try:
with open(progress_file, 'r') as f:
data = json.load(f)
if data.get("status") == "scanning":
with open(progress_file, 'w') as f:
json.dump({"status": "failed", "error": "Scan interrupted by server restart"}, f)
except Exception:
pass
origins = [
"http://localhost:5173", # Assuming frontend runs on this port during development
"http://127.0.0.1:5173",
# Add your production frontend URL(s) here when deploying
]
@asynccontextmanager
async def lifespan(app: FastAPI):
reset_stuck_scans()
start_scheduler()
yield
scheduler.shutdown()
app = FastAPI(lifespan=lifespan)
origins = ["*"]
app.add_middleware(
CORSMiddleware,
@@ -28,6 +47,12 @@ app.include_router(samba.router, prefix="/samba", tags=["samba"])
app.include_router(comics.router, prefix="/comics", tags=["comics"])
app.include_router(duplicates.router, prefix="/duplicates", tags=["duplicates"])
app.include_router(downloader.router, prefix="/downloader", tags=["downloader"])
app.include_router(qbittorrent.router, prefix="/qbittorrent", tags=["qbittorrent"])
app.include_router(system.router, prefix="/system", tags=["system"])
app.include_router(tasks.router, prefix="/tasks", tags=["tasks"])
app.include_router(settings.router, prefix="/settings", tags=["settings"])
app.include_router(stash.router, prefix="/stash", tags=["stash"])
app.include_router(scheduler_router.router, prefix="/scheduler", tags=["scheduler"])