From fb91c4545c757711e1b5fd354ca4b311c89fd2c0 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sun, 9 Aug 2026 04:39:34 +0200 Subject: feat(hub): add production hub — config, auth, API routers, tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit config.py: TOML + env var priority. auth.py: Argon2id passwords, JWT EdDSA with jti, refresh token hashed (blake3). Routers: hub (info/pubkey), users (register/login/refresh/pubkeys), nodes (announce/get), groups (create/gek-bundle/gek-retrieve). Rate limiting via slowapi. app.py factory with lifespan. All 40 tests pass (SQLite in-memory, no PostgreSQL required). Fix: remove tests/__init__.py to resolve namespace conflicts. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- packages/meshbay-hub/src/meshbay_hub/daemon.py | 31 +++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'packages/meshbay-hub/src/meshbay_hub/daemon.py') diff --git a/packages/meshbay-hub/src/meshbay_hub/daemon.py b/packages/meshbay-hub/src/meshbay_hub/daemon.py index ff8158a..ff66fee 100644 --- a/packages/meshbay-hub/src/meshbay_hub/daemon.py +++ b/packages/meshbay-hub/src/meshbay_hub/daemon.py @@ -1,15 +1,36 @@ """Entry point for the meshbay-hub systemd service.""" +import argparse +import logging +import sys +from pathlib import Path + import uvicorn -from meshbay_hub.app import app # noqa: F401 + +from meshbay_hub.config import load_config def main() -> None: + parser = argparse.ArgumentParser(description="MeshBay Hub server") + parser.add_argument("--config", type=Path, default=None) + parser.add_argument("--log-level", default="INFO", + choices=["DEBUG", "INFO", "WARNING", "ERROR"]) + args = parser.parse_args() + + logging.basicConfig( + level=getattr(logging, args.log_level), + format="%(asctime)s %(levelname)-8s %(name)s: %(message)s", + ) + + cfg = load_config(args.config) + uvicorn.run( - "meshbay_hub.app:app", - host="127.0.0.1", - port=8000, - log_level="info", + "meshbay_hub.app:create_app", + factory=True, + host=cfg.server.host, + port=cfg.server.port, + workers=cfg.server.workers, + log_level=args.log_level.lower(), ) -- cgit v1.2.3