Mirror test layout, domcontentloaded waits, backup DB writes outside threads

This commit is contained in:
2026-10-05 09:41:22 +02:00
parent 8f6c5be314
commit 622795c9a0
46 changed files with 296 additions and 241 deletions
+22 -7
View File
@@ -131,18 +131,33 @@ def offload(path):
return "ok" if result.returncode == 0 else f"failed: {result.stderr.strip()[:200]}"
def process_backup(row, codec):
try:
directory, stored_name, size = build_archive(row["uid"], row["target"], codec)
except Exception as exc:
update_backup(row["uid"], status="failed", error=str(exc)[:500], finished_at=now_iso())
record_system("backup.failed", actor_kind="service", origin="service", result="error", message=str(exc)[:200])
def finish_backup(row, archive=None, error=None):
if error is not None:
update_backup(row["uid"], status="failed", error=str(error)[:500], finished_at=now_iso())
record_system("backup.failed", actor_kind="service", origin="service", result="error", message=str(error)[:200])
return False
directory, stored_name, size = archive
update_backup(row["uid"], status="done", directory=directory, stored_name=stored_name, size_bytes=size, finished_at=now_iso())
record_system("backup.finished", actor_kind="service", origin="service", payload={"uid": row["uid"], "size": size})
return True
def process_backup(row, codec):
try:
archive = build_archive(row["uid"], row["target"], codec)
except Exception as exc:
return finish_backup(row, error=exc)
return finish_backup(row, archive=archive)
async def process_backup_async(row, codec):
try:
archive = await asyncio.to_thread(build_archive, row["uid"], row["target"], codec)
except Exception as exc:
return finish_backup(row, error=exc)
return finish_backup(row, archive=archive)
class BackupService(BaseService):
name = "backup"
title = "Back-ups"
@@ -178,7 +193,7 @@ class BackupService(BaseService):
self.log(f"automatische back-up ingepland: {cfg['schedule_target']}")
for row in pending_backups():
update_backup(row["uid"], status="running")
ok = await asyncio.to_thread(process_backup, row, cfg["codec"])
ok = await process_backup_async(row, cfg["codec"])
self.processed += 1
self.log(f"back-up {row['target']} {'klaar' if ok else 'mislukt'}")
primary = admin_uids_ordered()[:1]