Wire Taro social pages to social_svc (Centrifugo + live RTMP), drop multi-channel chat chrome, and add weapp WXSS sanitize/deploy helpers. Co-authored-by: Cursor <cursoragent@cursor.com>
91 lines
3.0 KiB
Python
91 lines
3.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Add /live/ FLV proxy next to social-api extension for www.nomadro.cn."""
|
|
from __future__ import annotations
|
|
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
HOST, USER, PASS = "82.157.112.245", "ubuntu", "Xiao4669805"
|
|
|
|
|
|
def main() -> int:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(
|
|
HOST,
|
|
username=USER,
|
|
password=PASS,
|
|
timeout=60,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
)
|
|
cmd = r"""
|
|
set -e
|
|
EXT_DIR=/www/server/panel/vhost/nginx/extension/www.nomadro.cn
|
|
sudo mkdir -p "$EXT_DIR"
|
|
echo '--- existing ---'
|
|
sudo ls -la "$EXT_DIR"
|
|
sudo cat "$EXT_DIR/social-api.conf" 2>/dev/null | head -40 || true
|
|
|
|
# write live-flv.conf
|
|
sudo tee "$EXT_DIR/live-flv.conf" >/dev/null <<'EOF'
|
|
# Nomadro social native live — SRS HTTP-FLV for WeChat LivePlayer
|
|
location /live/ {
|
|
proxy_pass http://127.0.0.1:1985/live/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
proxy_read_timeout 3600s;
|
|
proxy_send_timeout 3600s;
|
|
chunked_transfer_encoding on;
|
|
add_header Access-Control-Allow-Origin * always;
|
|
add_header Cache-Control no-cache always;
|
|
}
|
|
EOF
|
|
|
|
# also ensure www.nomadro.cn.conf exists and includes extension (baota usually does)
|
|
F=/www/server/panel/vhost/nginx/www.nomadro.cn.conf
|
|
if sudo test -f "$F"; then
|
|
echo "www conf exists"
|
|
sudo grep -n 'extension\|include\|server_name' "$F" | head -30
|
|
else
|
|
echo "www conf missing?"
|
|
sudo ls /www/server/panel/vhost/nginx | grep -i www || true
|
|
fi
|
|
|
|
sudo nginx -t
|
|
sudo systemctl reload nginx
|
|
|
|
echo '--- verify ---'
|
|
curl -sk -o /dev/null -w 'flv_public %{http_code}\n' 'https://nomadro.cn/live/smoke_smoke_peer_1.flv' || true
|
|
curl -sk -o /dev/null -w 'www_flv %{http_code}\n' 'https://www.nomadro.cn/live/smoke_smoke_peer_1.flv' || true
|
|
curl -sk -o /dev/null -w 'srs_local %{http_code}\n' 'http://127.0.0.1:1985/api/v1/versions' || true
|
|
curl -sk 'http://127.0.0.1:1985/api/v1/versions' | head -c 200; echo
|
|
curl -sk -X POST 'https://nomadro.cn/api/social/v1/live/rooms/demo/join' \
|
|
-H 'Content-Type: application/json' -H 'X-Social-Guest-Id: demo_a' \
|
|
-d '{"nick":"A"}' | head -c 350; echo
|
|
sudo docker ps --filter name=nomadro-srs --format '{{.Names}} {{.Status}} {{.Ports}}'
|
|
systemctl is-active nomadro-social
|
|
"""
|
|
_, stdout, _ = c.exec_command(cmd, timeout=120, get_pty=True)
|
|
while not stdout.channel.exit_status_ready():
|
|
if stdout.channel.recv_ready():
|
|
print(stdout.channel.recv(65536).decode("utf-8", "replace"), end="", flush=True)
|
|
time.sleep(0.05)
|
|
while stdout.channel.recv_ready():
|
|
print(stdout.channel.recv(65536).decode("utf-8", "replace"), end="", flush=True)
|
|
code = stdout.channel.recv_exit_status()
|
|
print(f"[exit {code}]", flush=True)
|
|
c.close()
|
|
return code
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|