fix: support containerized release runtimes
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { runGatewayApiServer } from './server.js';
|
||||
import { runGatewayOrchestrator } from './orchestrator/orchestratorServer.js';
|
||||
import { runProfileSeedCli } from './orchestrator/profileSeedCli.js';
|
||||
@@ -33,15 +30,12 @@ export * from './auth/kakaoClient.js';
|
||||
export * from './auth/oauthSessionStore.js';
|
||||
export * from './auth/postgresUserRepository.js';
|
||||
|
||||
const isMain = (): boolean => {
|
||||
if (!process.argv[1]) {
|
||||
return false;
|
||||
}
|
||||
return fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
|
||||
};
|
||||
const GATEWAY_ROLES = ['api', 'orchestrator', 'profile-seed'] as const;
|
||||
export const shouldRunGateway = (role: string | undefined): boolean =>
|
||||
typeof role === 'string' && GATEWAY_ROLES.includes(role as (typeof GATEWAY_ROLES)[number]);
|
||||
|
||||
if (isMain()) {
|
||||
const role = process.env.GATEWAY_ROLE ?? 'api';
|
||||
if (shouldRunGateway(process.env.GATEWAY_ROLE)) {
|
||||
const role = process.env.GATEWAY_ROLE;
|
||||
const run =
|
||||
role === 'orchestrator'
|
||||
? runGatewayOrchestrator
|
||||
|
||||
@@ -378,13 +378,14 @@ export const buildProcessDefinitions = (
|
||||
const runtimeWorkspace = profile.buildWorkspace ?? config.workspaceRoot;
|
||||
const frontendCwd = path.join(runtimeWorkspace, 'app', 'game-frontend');
|
||||
const frontendOutDir = buildProfileFrontendOutDir(runtimeWorkspace, profile.profileName);
|
||||
const frontendScript = path.join(runtimeWorkspace, 'node_modules', 'vite', 'bin', 'vite.js');
|
||||
const frontendScript = path.join(frontendCwd, 'node_modules', 'vite', 'bin', 'vite.js');
|
||||
const apiCwd = path.join(runtimeWorkspace, 'app', 'game-api');
|
||||
const daemonCwd = path.join(runtimeWorkspace, 'app', 'game-engine');
|
||||
const apiScript = path.join(apiCwd, 'dist', 'index.js');
|
||||
const daemonScript = path.join(daemonCwd, 'dist', 'index.js');
|
||||
const apiEnv = {
|
||||
...baseEnv,
|
||||
GAME_API_ROLE: 'server',
|
||||
PROFILE: profile.profile,
|
||||
SCENARIO: profile.scenario,
|
||||
GAME_PROFILE_NAME: profile.profileName,
|
||||
@@ -398,6 +399,7 @@ export const buildProcessDefinitions = (
|
||||
};
|
||||
const daemonEnv = {
|
||||
...baseEnv,
|
||||
GAME_ENGINE_ROLE: 'turn-daemon',
|
||||
TURN_PROFILE: profile.profile,
|
||||
PROFILE: profile.profile,
|
||||
SCENARIO: profile.scenario,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { shouldRunGateway } from '../src/index.js';
|
||||
|
||||
describe('gateway entrypoint', () => {
|
||||
it('starts only for an explicitly selected Gateway role', () => {
|
||||
expect(shouldRunGateway('api')).toBe(true);
|
||||
expect(shouldRunGateway('orchestrator')).toBe(true);
|
||||
expect(shouldRunGateway('profile-seed')).toBe(true);
|
||||
expect(shouldRunGateway('server')).toBe(false);
|
||||
expect(shouldRunGateway(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -118,7 +118,7 @@ describe('buildProcessDefinitions', () => {
|
||||
|
||||
expect(definitions.frontend).toMatchObject({
|
||||
cwd: path.join(buildWorkspace, 'app', 'game-frontend'),
|
||||
script: path.join(buildWorkspace, 'node_modules', 'vite', 'bin', 'vite.js'),
|
||||
script: path.join(buildWorkspace, 'app', 'game-frontend', 'node_modules', 'vite', 'bin', 'vite.js'),
|
||||
args: [
|
||||
'preview',
|
||||
'--host',
|
||||
|
||||
Reference in New Issue
Block a user