Add --check command for configuration and connectivity validation

Adds `python -m app --check` which verifies:
- All required environment variables are set
- Matrix homeserver is reachable
- Bot access token is valid
- Bot is a member of the announcements room
- Database path is writable

Uses color-coded pass/fail output with actionable hints on failure.
Configures nio with a 10-second timeout and no retries so checks
complete quickly even against unreachable servers.

https://claude.ai/code/session_01DuzWyMMXvLMB4VxEwJyV4X
This commit is contained in:
Claude
2026-02-28 08:06:24 +00:00
parent 8a2ce2a480
commit d636b9ed0e
3 changed files with 230 additions and 2 deletions

35
app/__main__.py Normal file
View File

@@ -0,0 +1,35 @@
"""CLI entry point for Melora.
Usage:
python -m app --check Verify configuration and connectivity
python -m app Start the server
"""
import argparse
import sys
def main() -> None:
parser = argparse.ArgumentParser(
prog="melora",
description="Melora — *arr media arrival webhook bridge for Matrix",
)
parser.add_argument(
"--check",
action="store_true",
help="verify configuration and connectivity, then exit",
)
args = parser.parse_args()
if args.check:
from app.check import run_checks
raise SystemExit(run_checks())
import uvicorn
uvicorn.run("app.main:app", host="0.0.0.0", port=8000)
if __name__ == "__main__":
main()