s'
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"""通过 Paramiko(SFTP + exec)部署到 ARM 板,无交互 SSH。日志写入 .deploy_logs/。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import os
|
||||
import posixpath
|
||||
import sys
|
||||
@@ -35,7 +36,13 @@ FILES = [
|
||||
"douyin_youtube_ffplay.py",
|
||||
"scripts/linux/install_hub.sh",
|
||||
"scripts/linux/reinstall_live_edge.sh",
|
||||
"scripts/linux/service_ctl.sh",
|
||||
"scripts/linux/lib/common.sh",
|
||||
"services/srs/docker-compose.yml",
|
||||
"services/neko/docker-compose.yml",
|
||||
"services/neko/chromium.conf",
|
||||
"services/neko/policies/policies.json",
|
||||
"services/neko/.gitignore",
|
||||
"live-platform/tools/render_caddyfile.py",
|
||||
"live-platform/tools/render_stack_env.py",
|
||||
"web-console/package.json",
|
||||
@@ -105,11 +112,19 @@ def mkdir_p(sftp: paramiko.SFTPClient, remote_dir: str) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def _shell_bytes_lf(data: bytes) -> bytes:
|
||||
"""Windows 工作区常见 CRLF;上传到 Linux 后 bash 会把 pipefail\\r 当成非法选项。"""
|
||||
return data.replace(b"\r\n", b"\n").replace(b"\r", b"\n")
|
||||
|
||||
|
||||
def sftp_put(sftp: paramiko.SFTPClient, local: Path, remote: str) -> None:
|
||||
remote = remote.replace("\\", "/")
|
||||
parent = posixpath.dirname(remote)
|
||||
mkdir_p(sftp, parent)
|
||||
sftp.put(str(local), remote)
|
||||
if local.suffix.lower() == ".sh":
|
||||
sftp.putfo(io.BytesIO(_shell_bytes_lf(local.read_bytes())), remote)
|
||||
else:
|
||||
sftp.put(str(local), remote)
|
||||
|
||||
|
||||
def connect() -> tuple[paramiko.SSHClient, paramiko.SFTPClient]:
|
||||
@@ -273,12 +288,19 @@ def main() -> int:
|
||||
f"echo '{PASS}' | sudo -S bash {REMOTE_BASE}/scripts/linux/reinstall_live_edge.sh",
|
||||
timeout=180,
|
||||
)
|
||||
# Caddy 刚 enable --now 时 bind :80 可能晚于立即 curl(曾出现 http_code=000)
|
||||
time.sleep(8)
|
||||
run_logged(
|
||||
client,
|
||||
log_path,
|
||||
"curl_port80_after_edge",
|
||||
"curl -sS -m 12 -o /dev/null -w 'http_code=%{http_code}\\n' http://127.0.0.1/ 2>&1 || echo curl_80_fail",
|
||||
timeout=20,
|
||||
"for i in 1 2 3 4 5; do "
|
||||
"code=$(curl -sS -m 8 -o /dev/null -w '%{http_code}' http://127.0.0.1/ 2>/dev/null || echo 000); "
|
||||
"echo \"try$i http_code=$code\"; "
|
||||
"[ \"$code\" = 200 ] && exit 0; "
|
||||
"sleep 3; "
|
||||
"done; exit 1",
|
||||
timeout=60,
|
||||
)
|
||||
|
||||
run_logged(
|
||||
|
||||
Reference in New Issue
Block a user