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>
66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "108.174.50.68"
|
|
REMOTE = r"""#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
export DY_PUBLIC_BASE_URL=https://dy.nomadro.live
|
|
export DY_NEKO_NAT1TO1=108.174.50.68
|
|
cd /opt/douyinWEB/backend
|
|
.venv/bin/python - <<'PY'
|
|
from app.db import init_db
|
|
from app import yt_assign_db, youtube_neko
|
|
init_db()
|
|
groups = yt_assign_db.list_groups(include_urls=False)
|
|
r = youtube_neko.sync_for_groups(groups)
|
|
print("sync_ok", r.get("ok"), "created", r.get("created"), "nat", r.get("nat1to1"))
|
|
for i in (1, 2):
|
|
try:
|
|
youtube_neko.instance_action(i, "start")
|
|
except Exception as e:
|
|
print("start_err", i, e)
|
|
s = youtube_neko._container_state(i)
|
|
print("state", i, "status", s.get("status"), "ready", s.get("ready"), "run", s.get("running"))
|
|
PY
|
|
nginx -t && systemctl reload nginx
|
|
echo PORTS:
|
|
docker ps -a --filter name=douyinweb-neko --format '{{.Names}} | {{.Status}} | {{.Ports}}'
|
|
echo CURL:
|
|
curl -sS -o /dev/null -w 'local=%{http_code}\n' http://127.0.0.1:9200/
|
|
curl -sS -o /dev/null -w 'nginx=%{http_code}\n' -k https://127.0.0.1/neko/1/ -H 'Host: dy.nomadro.live'
|
|
echo LOGS:
|
|
docker logs --tail 25 douyinweb-neko-1 2>&1 | tr -cd '\11\12\15\40-\176' | tail -25
|
|
# rebuild frontend only if needed (skip full build if already recent) — quick restart api
|
|
systemctl restart douyinweb-api
|
|
sleep 3
|
|
systemctl is-active douyinweb-api
|
|
cd /opt/douyinWEB/frontend && npm run build
|
|
systemctl restart douyinweb-web
|
|
sleep 3
|
|
systemctl is-active douyinweb-web
|
|
echo DONE
|
|
"""
|
|
|
|
|
|
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=600)
|
|
out = stdout.read().decode("utf-8", "replace")
|
|
err = stderr.read().decode("utf-8", "replace")
|
|
print(out)
|
|
if err.strip():
|
|
print("STDERR:", err[:2000])
|
|
code = stdout.channel.recv_exit_status()
|
|
print("exit", code)
|
|
c.close()
|
|
return code
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|