Files
chenproject/deploy.sh
douboer 7494c36ec7 update at 2026-10-12 17:19:48
GUI修复:状态栏精简不撑宽+原始采样图恢复显示;deploy排除gui.py
2026-10-12 17:19:48 +08:00

31 lines
1.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# deploy.sh —— 构建并部署展示网站到 m4(chenxy.biboer.cn,cloudflared → nginx:5050)
# 用法:
# ./deploy.sh 同步 core 到 web/py + rsync 到 m4 站点目录
# ./deploy.sh local 仅同步 core 到 web/py(本地预览用)
set -euo pipefail
REMOTE_HOST="m4" # ssh config 中的主机别名
SITE_DIR="/Users/gavin/www/chenxy" # m4 上 nginx 站点目录(nginx conf: servers/chenxy.biboer.cn.conf)
DOMAIN="chenxy.biboer.cn"
echo "[1/3] 同步算法核心 fiber_delay_sim -> web/py/"
rsync -a --delete --exclude '__pycache__' --exclude 'tests' \
--exclude 'experiments' --exclude 'export' --exclude 'cli.py' --exclude 'gui.py' \
fiber_delay_sim/ web/py/fiber_delay_sim/
if [ "${1:-}" = "local" ]; then
echo "[done] 本地预览:python3 -m http.server -d web 8766 → http://127.0.0.1:8766"
exit 0
fi
echo "[2/3] 上传 web/ -> ${REMOTE_HOST}:${SITE_DIR}/"
ssh -o RemoteCommand=none -o RequestTTY=no "$REMOTE_HOST" "mkdir -p ${SITE_DIR}"
rsync -az --delete -e "ssh -o RemoteCommand=none -o RequestTTY=no" web/ "${REMOTE_HOST}:${SITE_DIR}/"
echo "[3/3] 验证"
sleep 1
ssh -o RemoteCommand=none -o RequestTTY=no "$REMOTE_HOST" \
"curl -s -o /dev/null -w 'm4 localhost:5050 -> HTTP %{http_code}\\n' http://127.0.0.1:5050/"
echo "[done] 部署完成:https://${DOMAIN}(静态资源/算法文件已更新,刷新浏览器即可)"
echo "[hint] 若 nginx 配置有改动,需在 m4 上执行:sudo /opt/homebrew/bin/nginx -s reload"