Add a script to run devserver. Migrate to build and JS utils provided by fastapi-vue. Frontend directory renamed to frontend-build. Update Sanic, deprecations.

This commit is contained in:
2026-01-21 23:32:04 +00:00
parent 0d853032bf
commit ba6380e71e
10 changed files with 349 additions and 56 deletions
+2 -2
View File
@@ -15,12 +15,12 @@ fileserver = FileServer()
@bp.before_server_start
async def start_fileserver(app, _):
async def start_fileserver(app):
await fileserver.start()
@bp.after_server_stop
async def stop_fileserver(app, _):
async def stop_fileserver(app):
await fileserver.stop()
+6 -6
View File
@@ -36,19 +36,19 @@ setproctitle("cista-main")
@app.before_server_start
async def main_start(app, loop):
async def main_start(app):
config.load_config()
setproctitle(f"cista {config.config.path.name}")
workers = max(2, min(8, cpu_count()))
app.ctx.threadexec = ThreadPoolExecutor(
max_workers=workers, thread_name_prefix="cista-ioworker"
)
watching.start(app, loop)
watching.start(app)
# Sanic sometimes fails to execute after_server_stop, so we do it before instead (potentially interrupting handlers)
@app.before_server_stop
async def main_stop(app, loop):
async def main_stop(app):
quit.set()
watching.stop(app)
app.ctx.threadexec.shutdown()
@@ -75,7 +75,7 @@ async def use_session(req):
@app.before_server_start
def http_fileserver(app, _):
def http_fileserver(app):
bp = Blueprint("fileserver")
bp.on_request(auth.verify)
bp.static(
@@ -93,9 +93,9 @@ www = {}
def _load_wwwroot(www):
wwwnew = {}
base = Path(__file__).with_name("wwwroot")
base = Path(__file__).with_name("frontend-build")
paths = [PurePath()]
zstd = ZstdCompressor(level=10)
zstd = ZstdCompressor(level=18)
while paths:
path = paths.pop(0)
current = base / path
+2 -2
View File
@@ -440,14 +440,14 @@ def watcher_poll(loop):
quit.wait(0.1 + 8 * dur)
def start(app, loop):
def start(app):
global rootpath
config.load_config()
rootpath = config.config.path
use_inotify = sys.platform == "linux"
app.ctx.watcher = threading.Thread(
target=watcher_inotify if use_inotify else watcher_poll,
args=[loop],
args=[app.loop],
# Descriptive name for system monitoring
name=f"cista-watcher {rootpath}",
)