feat: manage nodes submenu with restart/delete
This commit is contained in:
parent
c6e163a767
commit
b981b82c5d
1 changed files with 22 additions and 6 deletions
|
|
@ -142,7 +142,6 @@ def main():
|
|||
print("\n─── Menu ───")
|
||||
print(" [1] Add a new node")
|
||||
|
||||
# List undeployed nodes as individual options
|
||||
n = 2
|
||||
node_map = {}
|
||||
for name in undeployed:
|
||||
|
|
@ -151,8 +150,7 @@ def main():
|
|||
n += 1
|
||||
|
||||
if deployed:
|
||||
print(f" [{n}] Show status"); n += 1
|
||||
print(f" [{n}] Remove a node"); n += 1
|
||||
print(f" [{n}] Manage nodes"); n += 1
|
||||
print(f" [{n}] Remote tunnel"); n += 1
|
||||
print(" [q] Quit")
|
||||
|
||||
|
|
@ -170,10 +168,8 @@ def main():
|
|||
str(nc.get("upstream_port","80")), "",
|
||||
nc.get("mode","monitoring"))
|
||||
deployed.add(name)
|
||||
elif c == str(n-3) and deployed:
|
||||
container_status()
|
||||
elif c == str(n-2) and deployed:
|
||||
remove_menu()
|
||||
manage_nodes()
|
||||
elif c == str(n-1):
|
||||
start_tunnel()
|
||||
elif c.lower() == "q":
|
||||
|
|
@ -277,3 +273,23 @@ def start_tunnel():
|
|||
print("Install paramiko: pip3 install paramiko")
|
||||
except Exception as e:
|
||||
print(f"Tunnel failed: {e}")
|
||||
|
||||
def manage_nodes():
|
||||
s = load_state().get("nodes", [])
|
||||
if not s: print("No nodes."); return
|
||||
while True:
|
||||
print("\n─── Manage Nodes ───")
|
||||
for i, n in enumerate(s):
|
||||
r = run(f"docker inspect -f '{{{{.State.Status}}}}' wallarm-{n['name']} 2>/dev/null")
|
||||
st = "●" if r.stdout.strip() == "running" else "○"
|
||||
print(f" [{i+1}] {st} {n['name']} (port {n.get('port','')})")
|
||||
print(" [r] Restart [d] Delete [b] Back")
|
||||
c = input("\nAction: ").strip()
|
||||
if c.lower() == 'b': break
|
||||
if c == 'r':
|
||||
name = input("Node name: ").strip()
|
||||
if name: run(f"docker restart wallarm-{name} 2>/dev/null"); print(f"Restarted {name}")
|
||||
elif c == 'd':
|
||||
name = input("Node name: ").strip()
|
||||
if name: remove_container(name)
|
||||
s = load_state().get("nodes", [])
|
||||
|
|
|
|||
Loading…
Reference in a new issue