fix(hub): resolve netstats import crash-loop
Some checks are pending
License Headers / check (push) Waiting to run

hub/api/main.py imported netstats as a top-level module, but netstats.py
ships inside the api/ package and the service runs uvicorn api.main:app
with WorkingDirectory=/usr/lib/secubox/hub — so the import failed with
ModuleNotFoundError and secubox-hub crash-looped (~9000 restarts on the
live USB image). Use a relative import with a top-level fallback (the
collector adds api/ to sys.path explicitly, so it keeps working).

Bumps secubox-hub 1.5.0 -> 1.5.1.
This commit is contained in:
CyberMind-FR 2026-06-29 06:23:16 +02:00
parent fb07e679e8
commit 658ae8a368
2 changed files with 16 additions and 1 deletions

View File

@ -14,6 +14,9 @@ import asyncio
import os
import time
from pathlib import Path
try:
from . import netstats # uvicorn `api.main:app` / aggregator import
except ImportError: # standalone with api/ on sys.path (collector)
import netstats # #758 — shared collector/reader module
app = FastAPI(title="secubox-hub", version="1.7.0", root_path="/api/v1/hub")

View File

@ -1,3 +1,15 @@
secubox-hub (1.5.1-1~bookworm1) bookworm; urgency=medium
* fix(#758): hub crash-loop — `import netstats` could not resolve.
netstats.py ships in the api/ package, but the service runs
`uvicorn api.main:app` with WorkingDirectory=/usr/lib/secubox/hub,
so the bare top-level import failed with ModuleNotFoundError and the
unit restarted ~9000 times. main.py now does `from . import netstats`
with a fallback to the top-level import (kept for the collector, which
adds api/ to sys.path explicitly). No API change.
-- Gerald KERMA <devel@cybermind.fr> Mon, 29 Jun 2026 10:30:00 +0200
secubox-hub (1.5.0-1~bookworm1) bookworm; urgency=medium
* feat(#758): nft-based network-stats collector — root oneshot+timer samples