Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
import paramiko
|
|
|
|
HOST = "108.174.50.68"
|
|
|
|
REMOTE = r"""#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
source /etc/douyinweb.env 2>/dev/null || true
|
|
export DY_PUBLIC_BASE_URL="${DY_PUBLIC_BASE_URL:-${PUBLIC_BASE:-https://dy.nomadro.live}}"
|
|
export DY_NEKO_NAT1TO1="${DY_NEKO_NAT1TO1:-108.174.50.68}"
|
|
cd /opt/douyinWEB/backend
|
|
.venv/bin/python - <<'PY'
|
|
from app.config import settings
|
|
from app import youtube_neko, yt_assign_db
|
|
from app.db import init_db
|
|
init_db()
|
|
groups = yt_assign_db.list_groups(include_urls=False)
|
|
print("public_base_url", settings.public_base_url or __import__('os').environ.get('DY_PUBLIC_BASE_URL'))
|
|
r = youtube_neko.sync_for_groups(groups)
|
|
print("sync", r)
|
|
ng = youtube_neko.sync_nginx_proxy(r.get('desired', 2) or 2)
|
|
print("nginx", ng)
|
|
for i in (1, 2):
|
|
s = youtube_neko._container_state(i)
|
|
print(i, s.get("status"), s.get("studio_url"))
|
|
PY
|
|
ls -la /etc/nginx/conf.d/douyinweb-neko* 2>/dev/null || true
|
|
nginx -t && systemctl reload nginx
|
|
systemctl restart douyinweb-api
|
|
sleep 3
|
|
systemctl is-active douyinweb-api
|
|
"""
|
|
|
|
|
|
def main() -> int:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False)
|
|
stdin, stdout, stderr = c.exec_command(REMOTE, timeout=120)
|
|
print(stdout.read().decode("utf-8", "replace"))
|
|
err = stderr.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print("STDERR:", err)
|
|
print("exit", stdout.channel.recv_exit_status())
|
|
c.close()
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|