chore: exclude local resource artifacts from main sync
This commit is contained in:
40
etc/servers/work-server/src/routes/server-command.ts
Executable file → Normal file
40
etc/servers/work-server/src/routes/server-command.ts
Executable file → Normal file
@@ -19,6 +19,36 @@ const restartReservationBodySchema = z.object({
|
||||
autoExecuteDelaySeconds: z.number().int().min(1).max(300).optional(),
|
||||
});
|
||||
|
||||
function getImmediateRestartBlockInfo(
|
||||
key: z.infer<typeof serverCommandParamSchema>['key'],
|
||||
workloadSummary: Awaited<ReturnType<typeof getRestartReservationWorkloadSummary>>,
|
||||
) {
|
||||
const codexPendingCount = workloadSummary.codexRunningCount + workloadSummary.codexQueuedCount;
|
||||
const automationPendingCount = workloadSummary.automationRunningCount + workloadSummary.automationQueuedCount;
|
||||
|
||||
if (key === 'test') {
|
||||
const pendingCount = codexPendingCount + automationPendingCount;
|
||||
|
||||
if (pendingCount > 0) {
|
||||
return {
|
||||
pendingCount,
|
||||
message: `진행 중인 Codex Live/자동화 작업 ${pendingCount}건이 있어 즉시 재기동할 수 없습니다. 재기동 예약을 사용해 주세요.`,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (key === 'work-server' && automationPendingCount > 0) {
|
||||
return {
|
||||
pendingCount: automationPendingCount,
|
||||
message: `진행 중인 자동화 작업 ${automationPendingCount}건이 있어 즉시 재기동할 수 없습니다. 재기동 예약을 사용해 주세요.`,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getRequestAccessToken(request: FastifyRequest) {
|
||||
const tokenHeader = request.headers['x-access-token'];
|
||||
return Array.isArray(tokenHeader) ? tokenHeader[0]?.trim() ?? '' : String(tokenHeader ?? '').trim();
|
||||
@@ -75,17 +105,13 @@ export async function registerServerCommandRoutes(app: FastifyInstance) {
|
||||
|
||||
if (key === 'test' || key === 'work-server') {
|
||||
const workloadSummary = await getRestartReservationWorkloadSummary();
|
||||
const pendingCount =
|
||||
workloadSummary.codexRunningCount
|
||||
+ workloadSummary.codexQueuedCount
|
||||
+ workloadSummary.automationRunningCount
|
||||
+ workloadSummary.automationQueuedCount;
|
||||
const blockInfo = getImmediateRestartBlockInfo(key, workloadSummary);
|
||||
|
||||
if (pendingCount > 0) {
|
||||
if (blockInfo) {
|
||||
reply.status(409);
|
||||
return {
|
||||
ok: false,
|
||||
message: `진행 중인 Codex Live/자동화 작업 ${pendingCount}건이 있어 즉시 재기동할 수 없습니다. 재기동 예약을 사용해 주세요.`,
|
||||
message: blockInfo.message,
|
||||
workloadSummary,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user