This commit is contained in:
commit
5ec99ce227
668 files changed
+164448
No files matched your search
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
# C 步(在 106 上跑):把生产 Worker agent 装成 systemd 单元
|
||||
# · env 与 47 的生产实例侧对齐(DSH_INSTANCE_* 必须一致 —— 实例是在 Worker 上 spawn 的)
|
||||
# · token 走 env 文件(600)而不是命令行,避免 ps 泄露
|
||||
# · 反向隧道复用演练时那把 key(其公钥已在 47 的 authorized_keys 里,restrict,port-forwarding)
|
||||
set -uo pipefail
|
||||
. "$(cd "$(dirname "$0")/.." && pwd)/config/load.sh"
|
||||
# 凭据 / 地址一律来自配置(config/platform.env)—— ⛔ 不在脚本里写死
|
||||
TOKEN="${DSH_PEER_AGENT_TOKEN:?config/platform.env 缺 DSH_PEER_AGENT_TOKEN}"
|
||||
|
||||
cat > /etc/dshs-worker.env <<ENV
|
||||
# DSHS 集群 Worker(2026-09-15 切换)—— 与 47 /etc/dshs.env 的**实例侧**条目保持一致
|
||||
DSHS_DATA_ROOT=$DSHS_DATA_ROOT
|
||||
DSHS_ISOLATION_MODE=account
|
||||
DSHS_DSH_BIN=/usr/bin/dsh
|
||||
DSHS_BASE_UID=100000
|
||||
DSH_INSTANCE_NODE_OPTIONS=--max-old-space-size=160
|
||||
DSH_INSTANCE_UNIVER_SOCKET=auto
|
||||
# 控制通道:Worker 主动拨 Manager 的反向隧道(公网入方向被云安全组挡住 ⇒ 只能这个方向)
|
||||
DSHS_CLUSTER_AGENT_TOKEN=$TOKEN
|
||||
DSHS_TUNNEL_TARGET=$DSHS_TUNNEL_TARGET
|
||||
DSHS_TUNNEL_IDENTITY=/root/.ssh/tunnel_ed25519
|
||||
ENV
|
||||
chmod 600 /etc/dshs-worker.env
|
||||
|
||||
cat > /etc/systemd/system/dshs-worker.service <<UNIT
|
||||
[Unit]
|
||||
Description=DSHS cluster worker agent (hosts per-user dsh instances on 106)
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
EnvironmentFile=/etc/dshs-worker.env
|
||||
ExecStart=/usr/bin/node $DSH_INSTALL_DIR-cluster/lib/cli.js worker --port 19000 --host 127.0.0.1 --host-id $DSH_PEER_HOST_ID --instance-host 127.0.0.1 --log-level info
|
||||
Restart=on-failure
|
||||
RestartSec=3
|
||||
KillMode=mixed
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
UNIT
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable dshs-worker >/dev/null 2>&1
|
||||
echo " 单元已装并 enable;token 长度=${#TOKEN}"
|
||||
|
||||
# 旧的手工 agent 若在跑先停(按端口定位)
|
||||
pid=$(ss -lntpH 'sport = :19000' 2>/dev/null | grep -oP 'pid=\K[0-9]+' | head -1)
|
||||
[ -n "$pid" ] && kill "$pid" && sleep 2 && echo " 已停旧的手工 agent pid=$pid"
|
||||
|
||||
systemctl restart dshs-worker
|
||||
sleep 6
|
||||
echo " dshs-worker=$(systemctl is-active dshs-worker)"
|
||||
echo " healthz: $(curl -s -m 6 http://127.0.0.1:19000/healthz | head -c 200)"
|
||||
Reference in new issue
Block a user