#!/usr/bin/env python3 """Stop orphan neko-10 on dy.live (DB neko_enabled=0). Do not touch FFmpeg.""" 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( "108.174.50.68", 22, "root", "Xiao4669805", timeout=40, allow_agent=False, look_for_keys=False, banner_timeout=120, ) break except Exception as e: print("retry", e, flush=True) time.sleep(2) else: raise SystemExit("ssh fail") _i, o, e = c.exec_command( r""" set -e cd /opt/douyinWEB/backend EN=$(./.venv/bin/python - <<'PY' from app.db import _connect, _lock with _lock: conn=_connect() r=conn.execute("SELECT neko_enabled FROM yt_assign_groups WHERE neko_instance_id=10 LIMIT 1").fetchone() print(int(r[0]) if r else -1) PY ) echo neko10_enabled=$EN if [ "$EN" = "0" ]; then docker stop douyinweb-neko-10 || true docker update --restart=no douyinweb-neko-10 2>/dev/null || true echo stopped_orphan_neko10 else echo skip_enabled_$EN fi sleep 2 docker ps --filter name=neko --format '{{.Names}} {{.Status}}' uptime mpstat 1 2 2>/dev/null | tail -4 ps aux --sort=-%cpu | head -8 """, timeout=90, ) print((o.read() + e.read()).decode("utf-8", "replace"), flush=True) c.close() print("ALL_DONE", flush=True)