仓库版 ExecStart 只带 --websearch-mcp,生产主机现行 unit 在此之外 还带 --seed-skills --imagegen-mcp --playwright-mcp;按仓库重装会静默 丢掉技能播种与两路 MCP。同步后仓库 ExecStart 与主机现行 ExecStart 逐 token 一致,并补 deploy/tests/test_autoscaler_unit.py(5 项)拦 后续漂移:四项齐全、无重复、均在 cloud/worker.py 有定义、不在 scaler 侧、--docker-runtime 仍为 runsc。 (cherry picked from commit bc3a23fc068cac189c0173b8e1c2befa7b832ed2)
29 lines
2.3 KiB
Desktop File
29 lines
2.3 KiB
Desktop File
[Unit]
|
||
Description=Codex cloud autoscaler (scales worker processes by queue depth)
|
||
After=codex-cloud-server.service
|
||
Wants=codex-cloud-server.service
|
||
|
||
[Service]
|
||
Type=simple
|
||
User=codexsvc
|
||
Group=codexsvc
|
||
WorkingDirectory=/opt/codex-app-server
|
||
EnvironmentFile=/etc/codex-app-server/env
|
||
# scaler 自身参数在前,`--` 之后是传给 cloud.worker 的参数。
|
||
# 不要在这里写 --worker-id / --worker-capacity / --loop,
|
||
# scaler 会按实例强制追加;--db 只给 scaler,scaler 会补给 worker。
|
||
# 注意:启用 autoscaler 后必须停掉静态 codex-cloud-worker,
|
||
# 否则两边同时派任务(scaler 只管理 autoscale-* 实例)。
|
||
# worker 侧 MCP/技能播种四项与生产主机现行 unit 一致
|
||
# (--websearch-mcp --seed-skills --imagegen-mcp --playwright-mcp);
|
||
# 主机 unit 再改时须同步改这里,deploy/tests/test_autoscaler_unit.py 会拦漂移。
|
||
ExecStart=/usr/bin/python3 -m cloud.autoscaler --db /var/lib/codex-app-server/control.db --interval 30 --min-workers 1 --max-workers 2 --per-worker-capacity 2 --scale-down-after 3 --drain-timeout 60 --state-file /var/lib/codex-app-server/autoscaler-state.json --log-dir /var/lib/codex-app-server/autoscaler-logs -- --interval 10 --config /opt/codex-app-server/host-config-docker.json --executor docker --docker-image codex-app-server:latest --docker-user 1003:1004 --docker-cpus 2 --docker-memory 2g --docker-extra-mounts /opt/codex-app-server/work:/app/work,/var/lib/codex-app-server/codex-home:/var/lib/codex-app-server/codex-home,/var/lib/codex-app-server/repos:/var/lib/codex-app-server/repos,/var/lib/codex-app-server/test-repo:/var/lib/codex-app-server/test-repo --repos-dir /var/lib/codex-app-server/repos --tenant-isolation --tenants-root /var/lib/codex-app-server/tenants --tenant-template-home /var/lib/codex-app-server/codex-home --tenant-template-repo /var/lib/codex-app-server/test-repo --docker-security-opt apparmor=docker-codex --docker-pids-limit 512 --egress-proxy-port 8888 --docker-runtime runsc --websearch-mcp --seed-skills --imagegen-mcp --playwright-mcp
|
||
Restart=on-failure
|
||
RestartSec=10
|
||
# 停 scaler 时要等它把 worker 优雅排空(drain 60 秒 + 缓冲),
|
||
# 默认 90 秒不够,放到 180 秒;超时后 systemd 再 SIGKILL。
|
||
TimeoutStopSec=180
|
||
|
||
[Install]
|
||
WantedBy=multi-user.target
|