修正 API 部署自测 worker 模拟
补齐 fake systemctl 对默认 worker 自动启用后的 list-units 模拟 避免 production-api-deploy 自测在 worker 自动启用路径误失败
This commit is contained in:
@@ -907,6 +907,7 @@ function prepareFixture(name) {
|
||||
const maintenanceFile = path.join(root, 'maintenance', 'enabled');
|
||||
const fakeBin = path.join(root, 'bin');
|
||||
const commandsLog = path.join(root, 'commands.log');
|
||||
const workerStateFile = path.join(root, 'worker-service-enabled');
|
||||
const version = `20260614-${name}`;
|
||||
|
||||
mkdirSync(sourceDir, { recursive: true });
|
||||
@@ -1086,8 +1087,21 @@ function prepareFixture(name) {
|
||||
path.join(fakeBin, 'systemctl'),
|
||||
[
|
||||
'#!/usr/bin/env bash',
|
||||
'set -euo pipefail',
|
||||
`printf 'systemctl %s\\n' "$*" >> ${shellQuote(commandsLog)}`,
|
||||
'if [[ "$1 $2 $3" == "is-active --quiet genarrative-pingora-gateway.service" && "${FAKE_PINGORA_ACTIVE:-true}" == "false" ]]; then',
|
||||
'worker_state_file="${FAKE_WORKER_STATE_FILE}"',
|
||||
'if [[ "$1" == "list-units" ]]; then',
|
||||
' pattern="${@: -1}"',
|
||||
' if [[ "${pattern}" == "genarrative-external-generation-worker@*.service" && -f "${worker_state_file}" ]]; then',
|
||||
' printf "genarrative-external-generation-worker@1.service loaded active running Genarrative external generation worker\\n"',
|
||||
' fi',
|
||||
' exit 0',
|
||||
'fi',
|
||||
'if [[ "$1 $2" == "enable --now" && "${3:-}" == "genarrative-external-generation-worker@1.service" ]]; then',
|
||||
' printf "enabled\\n" > "${worker_state_file}"',
|
||||
' exit 0',
|
||||
'fi',
|
||||
'if [[ "$1 $2 ${3:-}" == "is-active --quiet genarrative-pingora-gateway.service" && "${FAKE_PINGORA_ACTIVE:-true}" == "false" ]]; then',
|
||||
' exit 3',
|
||||
'fi',
|
||||
'exit 0',
|
||||
@@ -1136,6 +1150,7 @@ function prepareFixture(name) {
|
||||
maintenanceFile,
|
||||
fakeBin,
|
||||
commandsLog,
|
||||
workerStateFile,
|
||||
version,
|
||||
};
|
||||
}
|
||||
@@ -1204,6 +1219,7 @@ function runDeploy(fixture, options = {}) {
|
||||
options.createReleaseDuringCopy === true ? 'true' : 'false',
|
||||
FAKE_RELEASE_ROOT: fixture.releaseRoot,
|
||||
FAKE_RELEASE_VERSION: fixture.version,
|
||||
FAKE_WORKER_STATE_FILE: fixture.workerStateFile,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user