feat: add deployer

This commit is contained in:
2026-08-24 09:44:59 +08:00
parent 31bc5f45ce
commit e4d4319919
20 changed files with 1971 additions and 288 deletions
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
"""列出仓库内所有可部署服务及其目标节点。"""
from __future__ import annotations
import os
import sys
from collections import defaultdict
from lib import discover_services, project_root
def main() -> int:
root = project_root()
os.chdir(root)
services = discover_services()
if not services:
print("未找到任何可部署服务(需 compose.yaml 且能解析 node")
return 0
by_node: dict[str, list[str]] = defaultdict(list)
for info in services:
rel = os.path.relpath(info["service_dir"], root)
by_node[info["node"]].append(rel)
print(f"{len(services)} 个服务,分布在 {len(by_node)} 个节点:\n")
for node in sorted(by_node):
print(f"[{node}]")
for service in by_node[node]:
print(f" - {service}")
print()
return 0
if __name__ == "__main__":
sys.exit(main())