fix(api): stop a service's sys.exit from killing the serve process

Catch SystemExit at service import, in the heartbeat task, the 5xx middleware, search, samples and chapters, and answer it as SERVICE_ERROR.
This commit is contained in:
imSp4rky
2026-10-29 11:23:53 -06:00
parent 7b927934e0
commit bd64f3a8c4
9 changed files with 131 additions and 13 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ def load_service(path: Path) -> object:
tag = path.parent.stem
try:
module = import_module_by_path(path)
except Exception as e:
except (Exception, SystemExit) as e:
hint = compiled_import_hint(e.name, path) if isinstance(e, ModuleNotFoundError) and e.name else ""
raise RuntimeError(f"{tag}: failed to import - {type(e).__name__}: {e}{hint} ({path.name})") from e
try: