HA stage 2: DB-shared rate limiting + second server unit + monitor both-servers check (#52)
Co-authored-by: host <host@test.local>
This commit is contained in:
1 parent
fc8e337d0f
commit
06b9fd12fd
4 files changed
+170
-19
No files matched your search
@@ -0,0 +1,20 @@
|
||||
# 第二台控制面(HA 阶段 2)。
|
||||
#
|
||||
# 注意:unit 文件不在 deploy tar 里,改动后须单独 scp 到
|
||||
# /etc/systemd/system/ 再 daemon-reload + enable + start。
|
||||
# 与 codex-cloud-server.service 完全相同,只改端口(8766):
|
||||
# 同代码、同 env、同 DB 连接串;nginx upstream 把两个端口都
|
||||
# 配上,任一挂了另一台继续接(webhook 去重在 DB 里,重复投递
|
||||
# 幂等)。WorkingDirectory 与 User 与一号机一致。
|
||||
[Unit]
|
||||
Description=Codex cloud control plane (second instance)
|
||||
After=network.target
|
||||
[Service]
|
||||
User=codexsvc
|
||||
WorkingDirectory=/opt/codex-app-server
|
||||
EnvironmentFile=/etc/codex-app-server/env
|
||||
ExecStart=/usr/bin/python3 -m cloud.server --host 127.0.0.1 --port 8766 --db /var/lib/codex-app-server/control.db
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
+6
-2
@@ -6,7 +6,8 @@
|
||||
# sh /opt/codex-app-server/deploy/monitor.sh --self-test
|
||||
#
|
||||
# 检查项(全部不需要密码、不读 env 文件):
|
||||
# server:systemctl is-active codex-cloud-server 为 active
|
||||
# server:systemctl is-active codex-cloud-server 与
|
||||
# codex-cloud-server-2 均为 active(HA 阶段 2 双机)
|
||||
# worker:codex-autoscaler 或 codex-cloud-worker 任一为 active
|
||||
# (autoscaler 接管后静态 worker 故意停用,只查静态会误报:
|
||||
# 2026-10-26 07:02:55 静态 worker 停用后每 5 分钟 worker fail,
|
||||
@@ -41,7 +42,10 @@ DISK_PATH=${MONITOR_DISK_PATH:-/var/lib/codex-app-server}
|
||||
if [ ! -d "$DISK_PATH" ]; then DISK_PATH="/"; fi
|
||||
|
||||
check_server() {
|
||||
if systemctl is-active codex-cloud-server >/dev/null 2>&1; then
|
||||
# HA 阶段 2:两台 server 都必须 active,任一挂了都算 fail
|
||||
# (单台 active 时 API 还能用,但冗余已丢,必须可见)。
|
||||
if systemctl is-active codex-cloud-server >/dev/null 2>&1 \
|
||||
&& systemctl is-active codex-cloud-server-2 >/dev/null 2>&1; then
|
||||
echo pass
|
||||
else
|
||||
echo fail
|
||||
|
||||
Reference in new issue
Block a user