新增外部生成controller进程角色与systemd服务 补齐队列统计procedure与spacetime-client绑定 更新生产部署脚本、健康巡检和server provision的worker/controller口径 新增容器worker smoke脚本并同步运维文档与团队记忆
105 lines
3.6 KiB
JavaScript
105 lines
3.6 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import {readFileSync} from 'node:fs';
|
|
|
|
const checks = [
|
|
{
|
|
file: 'deploy/systemd/genarrative-database-backup.service',
|
|
includes: '--restart-service-after genarrative-api.service',
|
|
reason: '生产冷备份恢复 SpacetimeDB 后必须显式拉起依赖它的 API 服务。',
|
|
},
|
|
{
|
|
file: 'deploy/systemd/genarrative-health-patrol.service',
|
|
includes: 'scripts/ops/production-health-patrol.mjs',
|
|
reason: '健康巡检 systemd service 必须调用随 API release 发布的巡检脚本。',
|
|
},
|
|
{
|
|
file: 'deploy/systemd/genarrative-health-patrol.timer',
|
|
includes: 'genarrative-health-patrol.service',
|
|
reason: '健康巡检 timer 必须绑定巡检 service。',
|
|
},
|
|
{
|
|
file: 'scripts/jenkins-server-provision.sh',
|
|
includes: 'genarrative-health-patrol.timer',
|
|
reason: 'Server-Provision 必须安装并启用健康巡检 timer。',
|
|
},
|
|
{
|
|
file: 'scripts/jenkins-server-provision.sh',
|
|
includes: 'genarrative-external-generation-controller.service',
|
|
reason: 'Server-Provision 必须安装并启用外部生成 worker controller。',
|
|
},
|
|
{
|
|
file: 'scripts/jenkins-server-provision.sh',
|
|
includes: 'genarrative-external-generation-worker@1.service',
|
|
reason: 'Server-Provision 必须启用外部生成保底 worker 实例。',
|
|
},
|
|
{
|
|
file: 'scripts/deploy/production-api-deploy.sh',
|
|
includes: 'ensure_default_worker_service',
|
|
reason: 'API Deploy 必须在缺少 worker 实例时补启动默认外部生成 worker。',
|
|
},
|
|
{
|
|
file: 'scripts/deploy/production-api-deploy.sh',
|
|
includes: 'wait_for_worker_services',
|
|
reason: 'API Deploy 必须等待外部生成 worker 实例 active。',
|
|
},
|
|
{
|
|
file: 'scripts/deploy/production-api-deploy.sh',
|
|
includes: 'wait_for_worker_controller_service',
|
|
reason: 'API Deploy 必须重启并验活外部生成 worker controller。',
|
|
},
|
|
{
|
|
file: 'deploy/systemd/genarrative-external-generation-worker@.service',
|
|
includes: 'GENARRATIVE_PROCESS_ROLE=external-generation-worker',
|
|
reason: '外部生成 worker 模板必须作为独立 worker 进程角色运行。',
|
|
},
|
|
{
|
|
file: 'deploy/systemd/genarrative-external-generation-controller.service',
|
|
includes: 'GENARRATIVE_PROCESS_ROLE=external-generation-controller',
|
|
reason: '外部生成 worker controller 必须作为独立进程角色运行。',
|
|
},
|
|
{
|
|
file: 'scripts/ops/production-health-patrol.mjs',
|
|
includes: 'checkActiveWorkerInstances',
|
|
reason: '生产健康巡检必须检查至少一个外部生成 worker 实例 active。',
|
|
},
|
|
{
|
|
file: 'scripts/build-production-release.sh',
|
|
includes: 'production-health-patrol.mjs',
|
|
reason: '生产 API release 必须携带健康巡检脚本。',
|
|
},
|
|
{
|
|
file: 'scripts/deploy/production-api-deploy.sh',
|
|
includes: 'production-health-patrol.mjs',
|
|
reason: 'API deploy 必须把健康巡检脚本复制到 current release。',
|
|
},
|
|
{
|
|
file: 'jenkins/Jenkinsfile.production-api-build',
|
|
includes: 'scripts/ops/production-health-patrol.mjs',
|
|
reason: 'API Build 归档必须包含健康巡检脚本。',
|
|
},
|
|
{
|
|
file: 'jenkins/Jenkinsfile.production-api-deploy',
|
|
includes: 'scripts/ops/production-health-patrol.mjs',
|
|
reason: 'API Deploy 复制上游产物时必须包含健康巡检脚本。',
|
|
},
|
|
];
|
|
|
|
let failed = false;
|
|
|
|
for (const check of checks) {
|
|
const content = readFileSync(check.file, 'utf8');
|
|
if (!content.includes(check.includes)) {
|
|
failed = true;
|
|
console.error(
|
|
`[check:production-ops] ${check.file} 缺少 ${check.includes}。${check.reason}`,
|
|
);
|
|
}
|
|
}
|
|
|
|
if (failed) {
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('[check:production-ops] OK');
|