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.2 KiB
Python
66 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy OAuth via ShellCrash proxy + verify Google reachability."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
HUB = ROOT / "backend" / "app" / "shorts_oauth.py"
|
|
|
|
|
|
def main():
|
|
g = paramiko.SSHClient()
|
|
g.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
g.connect("107.173.30.245", 4014, "eric", "4669805", timeout=40, banner_timeout=80, allow_agent=False, look_for_keys=False)
|
|
sftp = g.open_sftp()
|
|
sftp.put(str(HUB), "/tmp/_up_shorts_oauth.py")
|
|
sftp.close()
|
|
cmd = r"""
|
|
echo '4669805' | sudo -S -p '' bash -lc '
|
|
set -e
|
|
install -m 644 /tmp/_up_shorts_oauth.py /opt/douyinWEB/backend/app/shorts_oauth.py
|
|
cd /opt/douyinWEB/backend && .venv/bin/python -m py_compile app/shorts_oauth.py
|
|
# verify google via proxy
|
|
.venv/bin/python - <<PY
|
|
from app import shorts_oauth, egress_hub, shellcrash_hub
|
|
print("egress_mode", egress_hub.get_mode())
|
|
print("sc", shellcrash_hub.status().get("running"), shellcrash_hub.status().get("mixed_port"))
|
|
print("oauth_proxy", shorts_oauth._google_http_proxy())
|
|
import httpx, time
|
|
proxy = shorts_oauth._google_http_proxy()
|
|
t0=time.time()
|
|
try:
|
|
r = httpx.get("https://oauth2.googleapis.com/", proxy=proxy, timeout=20.0, trust_env=False)
|
|
print("google_via_proxy", r.status_code, "ms", int((time.time()-t0)*1000))
|
|
except Exception as e:
|
|
print("google_via_proxy_FAIL", type(e).__name__, e, "ms", int((time.time()-t0)*1000))
|
|
t0=time.time()
|
|
try:
|
|
r = httpx.get("https://oauth2.googleapis.com/", timeout=8.0, trust_env=False)
|
|
print("google_direct", r.status_code, "ms", int((time.time()-t0)*1000))
|
|
except Exception as e:
|
|
print("google_direct_FAIL", type(e).__name__, e, "ms", int((time.time()-t0)*1000))
|
|
PY
|
|
systemctl restart douyinweb-api
|
|
for i in $(seq 1 15); do
|
|
c=$(curl -sS -m 3 -o /dev/null -w "%{http_code}" http://127.0.0.1:8014/api/health || echo x)
|
|
echo health $c
|
|
[ "$c" = "200" ] && break
|
|
sleep 2
|
|
done
|
|
'
|
|
"""
|
|
_, o, e = g.exec_command(cmd, timeout=180)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"), flush=True)
|
|
g.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|