Files
dsh_shenxian/scripts/start-cluster-manager.sh
T
admin 452924d89c feat(config): 涉密内容外置到配置目录(档案 140)
把散落在代码里的真实部署值统一收进 config/,代码改为引用配置,
使仓库副本/开源导出不再带出生产域名、IP、内网路径与凭据。

新增 config/:platform.env.example(模板)· load.sh(shell 加载器)·
index.cjs(node 加载器)· README.md(键一览与优先级)。
真实值放 config/platform.env —— 已 .gitignore 排除,不入库、不进导出。

TS 侧新增 src/platform-paths.ts 作部署路径的唯一解析处(零副作用):
platformDir/stateDir/backupDir/artifactDir/installDir/scriptPath。
config.ts 接入这些字段;内置中继种子由生产 URL 改为空(改由
DSHS_OVERLAY_BOOTSTRAP_SEEDS 提供)。修掉 5 处硬编码绝对路径,
src/** 注释中性化 116 行/53 文件。

scripts/** 36 个内部运维脚本:真令牌/PG 口令/隧道目标/主机号/路径
一律改从配置取;web/wake.html 的注册域白名单改为运行时从
location.hostname 推导;test/** 夹具 119 行/13 文件改 RFC 2606/5737
保留值,并把「内置种子必须为空」固化为回归断言。

取证:tsc 0 错;npm test 373/375(唯一失败 lease 属既有);
全仓扫描(大小写不敏感)代码面涉密标识 = 0;已部署 47 并零回归
(/opt/dsh/* 未搬家,/var/lib/dshs/platform 未被误建)。
2026-09-19 15:12:19 +08:00

47 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
. "$(cd "$(dirname "$0")/.." && pwd)/config/load.sh"
# 起一台 **cluster 模式的 Manager**(T08 跨机演练用;在 Manager 那台机器上跑)。
#
# 现场的对照(2026-09-15 演练实测):
# · Manager 在 **47**(本脚本所在机器),监听 `127.0.0.1:13080`(**不公网暴露**)
# · Worker agent 在 **106**,经 SSH 反向隧道出现在本机 `127.0.0.1:<worker-port-b>` / `19001`
# · 控制面 PG 也在 **106**,经同一条隧道出现在本机 `127.0.0.1:<pg-port>`
# 用法:bash scripts/start-cluster-manager.sh (env 见下方 manager.env)
在 47 上:建 manager.env、bootstrap 管理员、起 cluster Manager(127.0.0.1:13080)
set -uo pipefail
cd "$DSH_INSTALL_DIR"-cluster || exit 1
cat > "$DSH_INSTALL_DIR"-cluster/manager.env <<ENVEOF
DSHS_DEPLOY_MODE=cluster
DSHS_DB_URL=$DSHS_DB_URL
DSHS_DATA_ROOT="$DSH_INSTALL_DIR"-cluster/data
DSHS_CLUSTER_HOST_ID=${DSHS_CLUSTER_HOST_ID:-m-1}
DSHS_CLUSTER_AGENT_URL=http://127.0.0.1:19000
DSHS_CLUSTER_AGENT_TOKEN=$DSHS_CLUSTER_AGENT_TOKEN
DSHS_CLUSTER_INSTANCE_HOST=127.0.0.1
DSHS_CLUSTER_WORKER_DATA_ROOT="$DSH_INSTALL_DIR"-cluster/live-data
DSHS_CLUSTER_CAPACITY_MB=-1
DSHS_CLUSTER_REGISTER_SELF=0
DSHS_CLUSTER_LEASE_TTL_MS=30000
ENVEOF
set -a
# shellcheck disable=SC1091
. "$DSH_INSTALL_DIR"-cluster/manager.env
set +a
echo "--- bootstrap 管理员 ---"
node lib/cli.js bootstrap-admin --username root --password crossmgr123 2>&1 | tail -1
echo "--- 起 Manager ---"
pkill -f "dshs-cluster/lib/cli.js --port 13080" 2>/dev/null
sleep 1
nohup node lib/cli.js --port 13080 --host 127.0.0.1 --log-level warn > /tmp/manager-47.log 2>&1 &
sleep 7
echo "--- 自检 ---"
echo " login.html : $(curl -s -o /dev/null -w '%{http_code}' -m 6 http://127.0.0.1:13080/login.html)"
echo " 进程 : $(pgrep -cf 'dshs-cluster/lib/cli.js --port 13080')"
echo " 日志尾部 :"
tail -4 /tmp/manager-47.log 2>/dev/null | sed 's/^/ /'