feat: complete auction menu parity
This commit is contained in:
@@ -817,6 +817,7 @@ export const adminRouter = router({
|
||||
profileName: profile.profileName,
|
||||
apiRunning: false,
|
||||
daemonRunning: false,
|
||||
auctionRunning: false,
|
||||
tournamentRunning: false,
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -26,6 +26,7 @@ export type LobbyProfileStatus = {
|
||||
runtime: {
|
||||
apiRunning: boolean;
|
||||
daemonRunning: boolean;
|
||||
auctionRunning: boolean;
|
||||
tournamentRunning: boolean;
|
||||
};
|
||||
korName: string;
|
||||
@@ -69,7 +70,10 @@ export class RepositoryProfileStatusService implements GatewayProfileStatusServi
|
||||
|
||||
private mapProfile(
|
||||
row: GatewayProfileRecord,
|
||||
runtimeMap: Map<string, { apiRunning: boolean; daemonRunning: boolean; tournamentRunning: boolean }>
|
||||
runtimeMap: Map<
|
||||
string,
|
||||
{ apiRunning: boolean; daemonRunning: boolean; auctionRunning: boolean; tournamentRunning: boolean }
|
||||
>
|
||||
): LobbyProfileStatus {
|
||||
const meta = row.meta;
|
||||
return {
|
||||
@@ -81,6 +85,7 @@ export class RepositoryProfileStatusService implements GatewayProfileStatusServi
|
||||
runtime: runtimeMap.get(row.profileName) ?? {
|
||||
apiRunning: false,
|
||||
daemonRunning: false,
|
||||
auctionRunning: false,
|
||||
tournamentRunning: false,
|
||||
},
|
||||
korName: (meta.korName as string | undefined) ?? row.profile,
|
||||
|
||||
@@ -39,6 +39,7 @@ export interface GatewayOrchestratorOptions {
|
||||
export interface ProfileRuntimeState {
|
||||
apiRunning: boolean;
|
||||
daemonRunning: boolean;
|
||||
auctionRunning: boolean;
|
||||
tournamentRunning: boolean;
|
||||
}
|
||||
|
||||
@@ -66,13 +67,18 @@ export const planProfileReconcile = (
|
||||
): { shouldStart: boolean; shouldStop: boolean } => {
|
||||
if (status === 'RUNNING' || status === 'PREOPEN' || status === 'PAUSED' || status === 'COMPLETED') {
|
||||
return {
|
||||
shouldStart: !(runtime.apiRunning && runtime.daemonRunning && runtime.tournamentRunning),
|
||||
shouldStart: !(
|
||||
runtime.apiRunning &&
|
||||
runtime.daemonRunning &&
|
||||
runtime.auctionRunning &&
|
||||
runtime.tournamentRunning
|
||||
),
|
||||
shouldStop: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
shouldStart: false,
|
||||
shouldStop: runtime.apiRunning || runtime.daemonRunning || runtime.tournamentRunning,
|
||||
shouldStop: runtime.apiRunning || runtime.daemonRunning || runtime.auctionRunning || runtime.tournamentRunning,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -273,8 +279,16 @@ const parseInstallOptions = (
|
||||
};
|
||||
};
|
||||
|
||||
const buildProcessName = (profileName: string, role: 'api' | 'daemon' | 'tournament'): string =>
|
||||
`sammo:${profileName}:${role === 'api' ? 'game-api' : role === 'daemon' ? 'turn-daemon' : 'tournament-worker'}`;
|
||||
const buildProcessName = (profileName: string, role: 'api' | 'daemon' | 'auction' | 'tournament'): string =>
|
||||
`sammo:${profileName}:${
|
||||
role === 'api'
|
||||
? 'game-api'
|
||||
: role === 'daemon'
|
||||
? 'turn-daemon'
|
||||
: role === 'auction'
|
||||
? 'auction-worker'
|
||||
: 'tournament-worker'
|
||||
}`;
|
||||
|
||||
const isMissingProcessError = (error: unknown): boolean =>
|
||||
error instanceof Error && /process or namespace not found/i.test(error.message);
|
||||
@@ -285,11 +299,13 @@ export const buildProcessDefinitions = (
|
||||
): {
|
||||
api: { name: string; script: string; cwd: string; env: Record<string, string> };
|
||||
daemon: { name: string; script: string; cwd: string; env: Record<string, string> };
|
||||
auction: { name: string; script: string; cwd: string; env: Record<string, string> };
|
||||
tournament: { name: string; script: string; cwd: string; env: Record<string, string> };
|
||||
} => {
|
||||
const baseEnv = { ...(config.baseEnv ?? {}) };
|
||||
const apiName = buildProcessName(profile.profileName, 'api');
|
||||
const daemonName = buildProcessName(profile.profileName, 'daemon');
|
||||
const auctionName = buildProcessName(profile.profileName, 'auction');
|
||||
const tournamentName = buildProcessName(profile.profileName, 'tournament');
|
||||
const runtimeWorkspace = profile.buildWorkspace ?? config.workspaceRoot;
|
||||
const apiCwd = path.join(runtimeWorkspace, 'app', 'game-api');
|
||||
@@ -327,6 +343,15 @@ export const buildProcessDefinitions = (
|
||||
cwd: daemonCwd,
|
||||
env: daemonEnv,
|
||||
},
|
||||
auction: {
|
||||
name: auctionName,
|
||||
script: apiScript,
|
||||
cwd: apiCwd,
|
||||
env: {
|
||||
...apiEnv,
|
||||
GAME_API_ROLE: 'auction-worker',
|
||||
},
|
||||
},
|
||||
tournament: {
|
||||
name: tournamentName,
|
||||
script: apiScript,
|
||||
@@ -376,11 +401,13 @@ const mapRuntimeStates = (profileNames: string[], processNames: Map<string, bool
|
||||
profileNames.map((profileName) => {
|
||||
const apiName = buildProcessName(profileName, 'api');
|
||||
const daemonName = buildProcessName(profileName, 'daemon');
|
||||
const auctionName = buildProcessName(profileName, 'auction');
|
||||
const tournamentName = buildProcessName(profileName, 'tournament');
|
||||
return {
|
||||
profileName,
|
||||
apiRunning: processNames.get(apiName) ?? false,
|
||||
daemonRunning: processNames.get(daemonName) ?? false,
|
||||
auctionRunning: processNames.get(auctionName) ?? false,
|
||||
tournamentRunning: processNames.get(tournamentName) ?? false,
|
||||
};
|
||||
});
|
||||
@@ -981,6 +1008,7 @@ export class GatewayOrchestrator implements GatewayOrchestratorHandle {
|
||||
try {
|
||||
await this.processManager.start(definitions.api);
|
||||
await this.processManager.start(definitions.daemon);
|
||||
await this.processManager.start(definitions.auction);
|
||||
await this.processManager.start(definitions.tournament);
|
||||
await this.repository.updateLastError(profile.profileName, null);
|
||||
return true;
|
||||
@@ -996,10 +1024,11 @@ export class GatewayOrchestrator implements GatewayOrchestratorHandle {
|
||||
private async stopProfile(profile: GatewayProfileRecord): Promise<void> {
|
||||
const apiName = buildProcessName(profile.profileName, 'api');
|
||||
const daemonName = buildProcessName(profile.profileName, 'daemon');
|
||||
const auctionName = buildProcessName(profile.profileName, 'auction');
|
||||
const tournamentName = buildProcessName(profile.profileName, 'tournament');
|
||||
const existingNames = new Set((await this.processManager.list()).map((process) => process.name));
|
||||
const failures: string[] = [];
|
||||
for (const name of [apiName, daemonName, tournamentName]) {
|
||||
for (const name of [apiName, daemonName, auctionName, tournamentName]) {
|
||||
if (!existingNames.has(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ const createHarness = (
|
||||
? [
|
||||
{ name: 'sammo:che:2:game-api', status: 'online' },
|
||||
{ name: 'sammo:che:2:turn-daemon', status: 'online' },
|
||||
{ name: 'sammo:che:2:auction-worker', status: 'online' },
|
||||
{ name: 'sammo:che:2:tournament-worker', status: 'online' },
|
||||
]
|
||||
: [],
|
||||
@@ -138,7 +139,7 @@ const createHarness = (
|
||||
};
|
||||
|
||||
describe('GatewayOrchestrator first-class operations', () => {
|
||||
it('starts both profile processes and records success', async () => {
|
||||
it('starts all profile processes and records success', async () => {
|
||||
const harness = createHarness(buildOperation('START'));
|
||||
|
||||
await harness.orchestrator.runOperationsNow();
|
||||
@@ -147,12 +148,13 @@ describe('GatewayOrchestrator first-class operations', () => {
|
||||
expect(harness.started.map((definition) => definition.name)).toEqual([
|
||||
'sammo:che:2:game-api',
|
||||
'sammo:che:2:turn-daemon',
|
||||
'sammo:che:2:auction-worker',
|
||||
'sammo:che:2:tournament-worker',
|
||||
]);
|
||||
expect(harness.completions).toEqual(['SUCCEEDED']);
|
||||
});
|
||||
|
||||
it('stops both profile processes and records success', async () => {
|
||||
it('stops all profile processes and records success', async () => {
|
||||
const harness = createHarness(buildOperation('STOP'));
|
||||
|
||||
await harness.orchestrator.runOperationsNow();
|
||||
@@ -161,11 +163,13 @@ describe('GatewayOrchestrator first-class operations', () => {
|
||||
expect(harness.stopped).toEqual([
|
||||
'sammo:che:2:game-api',
|
||||
'sammo:che:2:turn-daemon',
|
||||
'sammo:che:2:auction-worker',
|
||||
'sammo:che:2:tournament-worker',
|
||||
]);
|
||||
expect(harness.deleted).toEqual([
|
||||
'sammo:che:2:game-api',
|
||||
'sammo:che:2:turn-daemon',
|
||||
'sammo:che:2:auction-worker',
|
||||
'sammo:che:2:tournament-worker',
|
||||
]);
|
||||
expect(harness.completions).toEqual(['SUCCEEDED']);
|
||||
@@ -190,6 +194,7 @@ describe('GatewayOrchestrator first-class operations', () => {
|
||||
expect(harness.deleted).toEqual([
|
||||
'sammo:che:2:game-api',
|
||||
'sammo:che:2:turn-daemon',
|
||||
'sammo:che:2:auction-worker',
|
||||
'sammo:che:2:tournament-worker',
|
||||
]);
|
||||
expect(harness.completions).toEqual(['SUCCEEDED']);
|
||||
@@ -203,7 +208,7 @@ describe('GatewayOrchestrator first-class operations', () => {
|
||||
expect(harness.completions).toEqual(['FAILED']);
|
||||
});
|
||||
|
||||
it('attempts to stop both roles before reporting a partial PM2 failure', async () => {
|
||||
it('attempts to stop every role before reporting a partial PM2 failure', async () => {
|
||||
const harness = createHarness(buildOperation('STOP'), false, true);
|
||||
|
||||
await harness.orchestrator.runOperationsNow();
|
||||
@@ -211,11 +216,13 @@ describe('GatewayOrchestrator first-class operations', () => {
|
||||
expect(harness.stopped).toEqual([
|
||||
'sammo:che:2:game-api',
|
||||
'sammo:che:2:turn-daemon',
|
||||
'sammo:che:2:auction-worker',
|
||||
'sammo:che:2:tournament-worker',
|
||||
]);
|
||||
expect(harness.deleted).toEqual([
|
||||
'sammo:che:2:game-api',
|
||||
'sammo:che:2:turn-daemon',
|
||||
'sammo:che:2:auction-worker',
|
||||
'sammo:che:2:tournament-worker',
|
||||
]);
|
||||
expect(harness.completions).toEqual(['FAILED']);
|
||||
|
||||
@@ -29,6 +29,7 @@ describe('planProfileReconcile', () => {
|
||||
planProfileReconcile('RUNNING', {
|
||||
apiRunning: true,
|
||||
daemonRunning: false,
|
||||
auctionRunning: true,
|
||||
tournamentRunning: true,
|
||||
})
|
||||
).toEqual({ shouldStart: true, shouldStop: false });
|
||||
@@ -39,6 +40,7 @@ describe('planProfileReconcile', () => {
|
||||
planProfileReconcile('PREOPEN', {
|
||||
apiRunning: false,
|
||||
daemonRunning: false,
|
||||
auctionRunning: false,
|
||||
tournamentRunning: false,
|
||||
})
|
||||
).toEqual({ shouldStart: true, shouldStop: false });
|
||||
@@ -49,16 +51,29 @@ describe('planProfileReconcile', () => {
|
||||
planProfileReconcile('RUNNING', {
|
||||
apiRunning: true,
|
||||
daemonRunning: true,
|
||||
auctionRunning: true,
|
||||
tournamentRunning: true,
|
||||
})
|
||||
).toEqual({ shouldStart: false, shouldStop: false });
|
||||
});
|
||||
|
||||
it('restarts a running profile when only the auction worker is missing', () => {
|
||||
expect(
|
||||
planProfileReconcile('RUNNING', {
|
||||
apiRunning: true,
|
||||
daemonRunning: true,
|
||||
auctionRunning: false,
|
||||
tournamentRunning: true,
|
||||
})
|
||||
).toEqual({ shouldStart: true, shouldStop: false });
|
||||
});
|
||||
|
||||
it('stops processes for non-running profiles', () => {
|
||||
expect(
|
||||
planProfileReconcile('STOPPED', {
|
||||
apiRunning: false,
|
||||
daemonRunning: true,
|
||||
auctionRunning: false,
|
||||
tournamentRunning: false,
|
||||
})
|
||||
).toEqual({ shouldStart: false, shouldStop: true });
|
||||
@@ -69,6 +84,7 @@ describe('planProfileReconcile', () => {
|
||||
planProfileReconcile('RESERVED', {
|
||||
apiRunning: false,
|
||||
daemonRunning: false,
|
||||
auctionRunning: false,
|
||||
tournamentRunning: false,
|
||||
})
|
||||
).toEqual({ shouldStart: false, shouldStop: false });
|
||||
@@ -95,6 +111,11 @@ describe('buildProcessDefinitions', () => {
|
||||
});
|
||||
expect(definitions.daemon.cwd).toBe(path.join(buildWorkspace, 'app', 'game-engine'));
|
||||
expect(definitions.daemon.script).toBe(path.join(buildWorkspace, 'app', 'game-engine', 'dist', 'index.js'));
|
||||
expect(definitions.auction).toMatchObject({
|
||||
cwd: path.join(buildWorkspace, 'app', 'game-api'),
|
||||
script: path.join(buildWorkspace, 'app', 'game-api', 'dist', 'index.js'),
|
||||
env: { GAME_API_ROLE: 'auction-worker' },
|
||||
});
|
||||
expect(definitions.tournament).toMatchObject({
|
||||
cwd: path.join(buildWorkspace, 'app', 'game-api'),
|
||||
script: path.join(buildWorkspace, 'app', 'game-api', 'dist', 'index.js'),
|
||||
@@ -107,6 +128,7 @@ describe('buildProcessDefinitions', () => {
|
||||
|
||||
expect(definitions.api.cwd).toBe(path.join(processConfig.workspaceRoot, 'app', 'game-api'));
|
||||
expect(definitions.daemon.cwd).toBe(path.join(processConfig.workspaceRoot, 'app', 'game-engine'));
|
||||
expect(definitions.auction.cwd).toBe(path.join(processConfig.workspaceRoot, 'app', 'game-api'));
|
||||
expect(definitions.tournament.cwd).toBe(path.join(processConfig.workspaceRoot, 'app', 'game-api'));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user