# -*- coding: utf-8 -*- """docker restart neko-4/7 only (keep volumes/profiles). No switch changes.""" from __future__ import annotations import sys import time import urllib.request import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=40, allow_agent=False, look_for_keys=False) sftp = c.open_sftp() with sftp.file("/tmp/_neko47.sh", "w") as f: f.write( """#!/bin/bash set +e for id in 4 7; do N=douyinweb-neko-$id echo ===== restart $N ===== docker restart "$N" done sleep 8 for id in 1 2 3 4 5 6 7 8; do code=$(curl -sS -m 3 -o /dev/null -w '%{http_code}' http://127.0.0.1:$((9200+id-1))/ || echo x) echo neko$id=$code done for id in 4 7; do echo == status neko-$id == docker exec douyinweb-neko-$id supervisorctl status 2>/dev/null | head -10 done wg show wg-dy-cn | egrep 'handshake|transfer' """ ) sftp.close() _, o, e = c.exec_command("echo '4669805' | sudo -S -p '' bash /tmp/_neko47.sh", timeout=120) print((o.read() + e.read()).decode("utf-8", "replace")) c.close() time.sleep(2) for u in [ "https://dy.nomadro.com/neko/4/", "https://dy.nomadro.com/neko/7/", "https://dy.nomadro.cn/neko/4/", ]: try: with urllib.request.urlopen(u, timeout=15) as r: print(u, r.status) except Exception as ex: print(u, "ERR", ex)