#!/usr/bin/env python3 """Pause non-douyinWEB Docker stacks on dylive to free RAM for single Neko. Does NOT touch: sing-box, frpp, wg-quick, douyinweb-* containers/units. """ from __future__ import annotations import sys 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", 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False, banner_timeout=120, ) def run(cmd: str, t: int = 180) -> str: print("\n=====", cmd[:100].replace("\n", " "), flush=True) _i, o, e = c.exec_command(cmd, timeout=t) out = (o.read() + e.read()).decode("utf-8", "replace") print(out[-14000:] if len(out) > 14000 else out, flush=True) return out # Inventory first run( r""" set +e echo '=== before mem ===' free -h | head -3 echo '=== all containers ===' docker ps -a --format '{{.Names}}\t{{.Status}}\t{{.Image}}' | sort echo '=== compose projects ===' docker ps -a --format '{{.Label "com.docker.compose.project"}}\t{{.Names}}' | sort -u """ ) # Stop non-douyinWEB stacks by compose project / name patterns run( r""" set +e # Protect these name prefixes protect='douyinweb-|neko' stop_one() { local name="$1" case "$name" in douyinweb-*|douyinweb_*) echo "KEEP $name"; return 0 ;; esac echo "STOP $name" docker stop "$name" 2>/dev/null || true } # Explicit known non-project stacks from prior diag for n in \ nomadro-live-wp-wordpress-1 nomadro-live-wp-db-1 \ nomadro-wp-wordpress-1 nomadro-wp-db-1 \ deploy-nsqd-1 deploy-nsqadmin-1 deploy-nsqlookupd-1 \ ntfy-ntfy-1 \ umami-umami-1 umami-db-1 do stop_one "$n" done # Also stop any other running containers that are not douyinweb-* while read -r name; do [ -z "$name" ] && continue stop_one "$name" done < <(docker ps --format '{{.Names}}') echo '=== after stop ===' docker ps --format '{{.Names}}\t{{.Status}}' | sort sync; echo 3 > /proc/sys/vm/drop_caches 2>/dev/null || true free -h | head -3 # ensure untouchables still up systemctl is-active sing-box.service frpp.service wg-quick@wg-dy.service 2>/dev/null || true systemctl is-active douyinweb-api.service douyinweb-web.service 2>/dev/null || true docker ps --filter name=douyinweb-neko-12 --format '{{.Names}} {{.Status}}' """ ) c.close() print("DONE")