douyinWEB/scripts/_stop_dylive_wp_umami_nsq.py
2026-09-13 22:10:49 -05:00

62 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Stop WP / umami / nsq on dylive; leave douyinWEB + edge services alone."""
from __future__ import annotations
import sys
import time
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
for i in range(8):
try:
c.connect(
"107.173.30.245",
22,
"root",
"Xiao4669805",
timeout=50,
allow_agent=False,
look_for_keys=False,
banner_timeout=180,
)
break
except Exception as e:
print("retry", i, e, flush=True)
time.sleep(2 + i)
else:
raise SystemExit("ssh fail")
_i, o, e = c.exec_command(
r"""
set +e
echo '=== before (non-douyinweb) ==='
docker ps --format '{{.Names}}\t{{.Status}}' | grep -v douyinweb || true
free -m | head -2
# Match WP / umami / nsq only — do NOT touch ntfy, douyinweb, sing-box/frpp/wg
STOP_LIST=$(docker ps --format '{{.Names}}' | grep -E '^(nomadro-.*wp-|umami-|deploy-nsq)' || true)
echo "STOP_LIST=$STOP_LIST"
if [ -n "$STOP_LIST" ]; then
docker stop $STOP_LIST
fi
echo '=== after ==='
docker ps --format '{{.Names}}\t{{.Status}}'
echo '--- stopped targets ---'
docker ps -a --format '{{.Names}}\t{{.Status}}' | grep -E '^(nomadro-.*wp-|umami-|deploy-nsq)' || true
free -m | head -2
# ensure neko-12 still up
docker ps --filter name=douyinweb-neko-12 --format '{{.Names}} {{.Status}}'
systemctl is-active sing-box frpp 'wg-quick@wg-dy' 2>/dev/null || true
""",
timeout=180,
)
print((o.read() + e.read()).decode("utf-8", "replace"))
c.close()
print("DONE")