feat: add deployer
This commit is contained in:
Executable
+36
@@ -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())
|
||||
Reference in New Issue
Block a user