forked from retoor/devplacepy
Track the editor config, local Claude permissions and the maintenance scripts
.editorconfig fixes indentation and line endings for every editor. The scripts/ helpers (database import checks, the monolith guard, and the two refactor migrations) were only ever local.
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import importlib
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SERVICES_DIR = ROOT / "devplacepy_services"
|
||||
|
||||
SERVICES = [
|
||||
"web",
|
||||
"database",
|
||||
"pubsub",
|
||||
"gateway",
|
||||
"jobs",
|
||||
"devii",
|
||||
"bot",
|
||||
"backup",
|
||||
"containers",
|
||||
"telegram",
|
||||
"email",
|
||||
"news",
|
||||
"gitea",
|
||||
"audit",
|
||||
"xmlrpc",
|
||||
]
|
||||
|
||||
|
||||
def list_services() -> int:
|
||||
for name in SERVICES:
|
||||
main_py = SERVICES_DIR / name / "main.py"
|
||||
status = "ok" if main_py.exists() else "missing"
|
||||
print(f"{name:12} {status}")
|
||||
return 0
|
||||
|
||||
|
||||
def verify_stubs() -> int:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
errors: list[str] = []
|
||||
for name in SERVICES:
|
||||
main_py = SERVICES_DIR / name / "main.py"
|
||||
if not main_py.exists():
|
||||
errors.append(f"{name}: missing main.py")
|
||||
continue
|
||||
module_name = f"devplacepy_services.{name}.main"
|
||||
try:
|
||||
module = importlib.import_module(module_name)
|
||||
except Exception as exc:
|
||||
errors.append(f"{name}: import failed ({exc})")
|
||||
continue
|
||||
app = getattr(module, "app", None)
|
||||
if app is None:
|
||||
errors.append(f"{name}: no app export")
|
||||
continue
|
||||
try:
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
client = TestClient(app)
|
||||
resp = client.get("/health")
|
||||
if resp.status_code != 200:
|
||||
errors.append(f"{name}: /health returned {resp.status_code}")
|
||||
continue
|
||||
data = resp.json()
|
||||
for key in ("service", "status", "uptime_s", "version", "deps", "stats"):
|
||||
if key not in data:
|
||||
errors.append(f"{name}: health missing key {key}")
|
||||
except Exception as exc:
|
||||
errors.append(f"{name}: health check failed ({exc})")
|
||||
if errors:
|
||||
print("verify: failed")
|
||||
for err in errors:
|
||||
print(f" {err}")
|
||||
return 1
|
||||
print("verify: ok")
|
||||
return 0
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(prog="refactor_to_microservices.py")
|
||||
parser.add_argument("--list", action="store_true")
|
||||
parser.add_argument("--verify", action="store_true")
|
||||
args = parser.parse_args()
|
||||
if args.list:
|
||||
return list_services()
|
||||
if args.verify:
|
||||
return verify_stubs()
|
||||
parser.print_help()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user