Files
.pouch/skills/deployer/scripts/deploy/list.py
T
2026-08-24 09:44:59 +08:00

37 lines
935 B
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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())