# -*- coding: utf-8 -*- import paramiko HOST = "107.173.30.245" APP = "/opt/douyinWEB" WEB = 4015 API = 8014 c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False) cmd = f""" set -e systemctl stop douyinweb-web || true cat >/etc/systemd/system/douyinweb-web.service < {APP}/frontend/next.config.mjs <<'EOF' /** @type {{import('next').NextConfig}} */ const nextConfig = {{ reactStrictMode: true, async rewrites() {{ return [ {{ source: "/api/:path*", destination: "http://127.0.0.1:{API}/api/:path*" }}, {{ source: "/covers/:path*", destination: "http://127.0.0.1:{API}/covers/:path*" }}, ]; }}, }}; export default nextConfig; EOF cd {APP} git fetch origin && git reset --hard origin/main # restore rewrite after reset cat > frontend/next.config.mjs <<'EOF' /** @type {{import('next').NextConfig}} */ const nextConfig = {{ reactStrictMode: true, async rewrites() {{ return [ {{ source: "/api/:path*", destination: "http://127.0.0.1:{API}/api/:path*" }}, {{ source: "/covers/:path*", destination: "http://127.0.0.1:{API}/covers/:path*" }}, ]; }}, }}; export default nextConfig; EOF cd frontend && npm run build systemctl daemon-reload systemctl enable douyinweb-web systemctl restart douyinweb-api douyinweb-web sleep 7 ss -lntp | grep -E ':{WEB}|:{API}|:8333' systemctl is-active douyinweb-web douyinweb-api curl -s -o /dev/null -w 'web:%{{http_code}}\\n' --max-time 20 http://127.0.0.1:{WEB}/ curl -s http://127.0.0.1:{API}/api/sessions/active | python3 -c "import sys,json; d=json.load(sys.stdin); print('active',d.get('total')); [print(s.get('anchor_name'), s.get('cover_url')) for s in (d.get('sessions') or [])[:5]]" SID=$(curl -s http://127.0.0.1:{API}/api/sessions/active | python3 -c "import sys,json; d=json.load(sys.stdin); print((d.get('sessions') or [{{}}])[0].get('id',''))") curl -s -o /dev/null -w 'cover:%{{http_code}} size:%{{size_download}}\\n' --max-time 20 http://127.0.0.1:{API}/api/sessions/$SID/cover curl -s -o /dev/null -w 'cover_via_web:%{{http_code}}\\n' --max-time 20 http://127.0.0.1:{WEB}/api/sessions/$SID/cover """ _, o, _ = c.exec_command(cmd, timeout=600, get_pty=True) print(o.read().decode("utf-8", errors="replace")[-5000:]) c.close() print(f"\nOpen http://{HOST}:{WEB}/")