fix: support containerized release runtimes

This commit is contained in:
2026-08-04 14:45:47 +00:00
parent a044d97d77
commit 6e635a312f
17 changed files with 101 additions and 45 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
"scripts": {
"build": "tsdown -c ../../tsdown.config.ts -F @sammo-ts/game-engine",
"dev": "tsdown -c ../../tsdown.config.ts -F @sammo-ts/game-engine --watch",
"start": "pnpm run build && node dist/index.js",
"start": "pnpm run build && GAME_ENGINE_ROLE=turn-daemon node dist/index.js",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"profile:npc-unification-memory": "node scripts/profile-npc-unification-memory.mjs",
+2 -13
View File
@@ -1,6 +1,3 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { runTurnDaemonCli } from './turn/cli.js';
export * from './lifecycle/types.js';
@@ -29,17 +26,9 @@ export * from './turn/selectPoolService.js';
export * from './turn/turnDaemon.js';
export * from './turn/cli.js';
const isMain = (): boolean => {
if (typeof process.env.NODE_APP_INSTANCE === 'string') {
return true;
}
if (!process.argv[1]) {
return false;
}
return fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
};
export const shouldRunTurnDaemon = (role: string | undefined): boolean => role === 'turn-daemon';
if (isMain()) {
if (shouldRunTurnDaemon(process.env.GAME_ENGINE_ROLE)) {
runTurnDaemonCli().catch((error) => {
console.error('[turn-daemon] failed to start', error);
process.exitCode = 1;
+11
View File
@@ -0,0 +1,11 @@
import { describe, expect, it } from 'vitest';
import { shouldRunTurnDaemon } from '../src/index.js';
describe('game-engine entrypoint', () => {
it('starts only for an explicitly selected turn-daemon role', () => {
expect(shouldRunTurnDaemon('turn-daemon')).toBe(true);
expect(shouldRunTurnDaemon('api')).toBe(false);
expect(shouldRunTurnDaemon(undefined)).toBe(false);
});
});