Files
dsh_shenxian/dsh-server-docs/06-ops/scripts/switch-domain-alotbuy.sh
T
admin e6207aa691
build / build-and-scan (push) Waiting to run
chore(仓库对齐): 文档库结构治理 + IM/插件线落地
文档库:目录改为编号制(01-规范/02-架构设计/03-数据库/04-调整方案/
05-交接单/06-ops/07-scripts/08-skills/09-archive),顶层散文件归入 01-规范/;
INDEX.md 与 docs-manifest.json 重刷(档案 146 篇);旧目录名引用全量对齐。

IM 线:src/im/**(SDK / hub / store / presence / ws / gateway-token)、
src/web/routes/im.ts、src/db/plugin-data/**、src/supervisor/plugin-assembly.ts
及对应 test/**。

插件线:poc/{im-agent-bridge,im-connection-gateway,im-conversation-tabs,
business-plugins-im,carbon-mcp-probe}、src/web/routes/{sessions,overlay-device}.ts、
src/net/relay/{device-grant,instance-credential}.ts。

仓库卫生:清出 40 个历史误入库 / 已改名文件(34 个交接单归档 + 6 个旧结构,
本地均有副本);dsh-server-docs/.gitignore 补 tmp/;交接单不入库(政策)。
2026-09-24 07:25:16 +08:00

51 lines
1.9 KiB
Bash
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
# 切换 DSH 平台服务域名 → alotbuy.com(2026-09-10)
# 幂等;带备份;drain 采用「按 pid 结束」而非 pkill -f(避免杀掉自身 ssh 会话)
set -euo pipefail
NEW_BASE=alotbuy.com
NEW_COOKIE=.alotbuy.com
ENV=/etc/dshs.env
TS=$(date +%Y%m%d-%H%M)
echo "=== 1) 备份 env ==="
cp -a "$ENV" "$ENV.bak-$TS"
echo " 备份: $ENV.bak-$TS"
echo "=== 2) 写入新域名 ==="
sed -i "s|^DSHS_BASE_DOMAIN=.*|DSHS_BASE_DOMAIN=$NEW_BASE|" "$ENV"
sed -i "s|^DSHS_COOKIE_DOMAIN=.*|DSHS_COOKIE_DOMAIN=$NEW_COOKIE|" "$ENV"
grep -E 'BASE_DOMAIN|COOKIE_DOMAIN' "$ENV" | sed 's/^/ /'
echo "=== 3) drain:停编排器 → 结束残留实例/scope → 起编排器 ==="
systemctl stop dshs
sleep 2
# 3a. 按 pid 结束 dsh 子进程(uid 形如 dsh-xxxx)
for pid in $(ps -eo pid,user,args | awk '$2 ~ /^dsh-/ {print $1}'); do
kill "$pid" 2>/dev/null || true
done
# 3b. 结束 bwrap 包装进程(用 grep 中括号技巧避免匹配自身)
for pid in $(ps -eo pid,args | grep "[b]wrap --ro-bind" | awk '{print $1}'); do
kill "$pid" 2>/dev/null || true
done
sleep 2
# 3c. 收尾残留 scope
systemctl list-units --type=scope --all --no-legend 'dsh-*' 2>/dev/null | awk '{print $1}' | while read -r u; do
[ -n "$u" ] && systemctl stop "$u" 2>/dev/null || true
done
sleep 1
echo " 残留实例数: $(ps -eo user,args | grep -c '[d]sh --profile' || true)"
echo "=== 4) 启动编排器 ==="
systemctl start dshs
sleep 3
echo " 服务: $(systemctl is-active dshs) / enabled=$(systemctl is-enabled dshs)"
echo " 编排器 pid: $(pgrep -f lib/cli.js | head -1)"
echo "=== 5) 自检 ==="
curl -sk -o /dev/null -w " 源站 https://alotbuy.com/login.html → %{http_code}\n" \
--resolve alotbuy.com:443:127.0.0.1 https://alotbuy.com/login.html
curl -s -o /dev/null -w " 经 CF https://alotbuy.com/login.html → %{http_code}\n" -m 15 \
https://alotbuy.com/login.html
echo " 完成(旧域名 301 见 dsh.alotbuy.com.conf)"