# -*- coding: utf-8 -*- """Deploy: time-slot mode stays separate from 自动推流.""" from __future__ import annotations import sys from pathlib import Path import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") ROOT = Path(__file__).resolve().parents[1] HOST = "108.174.50.68" PASS = "Xiao4669805" REPO = "/opt/douyinWEB" FILES = [ "backend/app/youtube_relay_pipeline.py", "frontend/src/components/YtAssignPanel.tsx", ] def main() -> int: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, 22, "root", PASS, timeout=60, allow_agent=False, look_for_keys=False) sftp = c.open_sftp() for rel in FILES: sftp.put(str(ROOT / rel), f"{REPO}/{rel}") print("uploaded", rel) sftp.close() cmd = r""" set -e systemctl restart douyinweb-api cd /opt/douyinWEB/frontend && npm run build systemctl restart douyinweb-web sleep 2 systemctl is-active douyinweb-api douyinweb-web cd /opt/douyinWEB/backend .venv/bin/python - <<'PY' from app.db import init_db, get_settings_map from app.youtube_relay_pipeline import youtube_relay_pipeline as pipe import inspect init_db() src = inspect.getsource(pipe.set_time_slot_mode) assert "youtube_relay_enabled" not in src or "Does NOT turn on" in src assert 'patch["youtube_relay_enabled"]' not in src assert '"youtube_relay_enabled": True' not in src assert '"youtube_relay_enabled": on' not in src cfg = get_settings_map() print("ok_no_auto_enable") print("time_slot", cfg.get("youtube_relay_time_slot_mode")) print("auto_push", cfg.get("youtube_relay_enabled")) PY """ print("remote deploy…") _stdin, stdout, stderr = c.exec_command(cmd, timeout=360) out = stdout.read().decode("utf-8", "replace") err = stderr.read().decode("utf-8", "replace") code = stdout.channel.recv_exit_status() print(out[-4000:] if len(out) > 4000 else out) if err.strip(): print("STDERR:", err[-2000:]) print("exit", code) c.close() return code if __name__ == "__main__": raise SystemExit(main())