fix: isolate child PM2 arguments
This commit is contained in:
@@ -24,6 +24,7 @@ export interface ProcessManager {
|
||||
|
||||
const PM2_INTERNAL_ENV_KEYS = new Set([
|
||||
'NODE_APP_INSTANCE',
|
||||
'args',
|
||||
'autorestart',
|
||||
'autostart',
|
||||
'created_at',
|
||||
|
||||
@@ -179,6 +179,7 @@ describe('buildProcessDefinitions', () => {
|
||||
DATABASE_URL: 'postgresql://integration.invalid/sammo',
|
||||
VITE_APP_BASE_PATH: '/gateway',
|
||||
GATEWAY_ROLE: 'orchestrator',
|
||||
args: 'daemon',
|
||||
NODE_APP_INSTANCE: '2',
|
||||
name: 'sammo:gateway-orchestrator',
|
||||
pm_id: '2',
|
||||
@@ -189,6 +190,7 @@ describe('buildProcessDefinitions', () => {
|
||||
for (const definition of Object.values(definitions)) {
|
||||
expect(definition.env).toMatchObject({ DATABASE_URL: 'postgresql://integration.invalid/sammo' });
|
||||
expect(definition.env).not.toHaveProperty('pm_id');
|
||||
expect(definition.env).not.toHaveProperty('args');
|
||||
expect(definition.env).not.toHaveProperty('pm_exec_path');
|
||||
expect(definition.env).not.toHaveProperty('name');
|
||||
expect(definition.env).not.toHaveProperty('NODE_APP_INSTANCE');
|
||||
@@ -206,6 +208,7 @@ describe('sanitizeManagedProcessEnv', () => {
|
||||
PATH: '/usr/local/bin:/usr/bin',
|
||||
GATEWAY_ROLE: 'orchestrator',
|
||||
GAME_API_ROLE: 'server',
|
||||
args: 'daemon',
|
||||
NODE_APP_INSTANCE: '2',
|
||||
name: 'sammo:gateway-orchestrator',
|
||||
pm_id: '2',
|
||||
|
||||
@@ -11,6 +11,7 @@ describe('buildPm2StartOptions', () => {
|
||||
env: {
|
||||
DATABASE_URL: 'postgresql://integration.invalid/sammo',
|
||||
GAME_API_ROLE: 'server',
|
||||
args: 'daemon',
|
||||
pm_id: '2',
|
||||
pm_exec_path: '/srv/sammo/app/gateway-api/dist/index.js',
|
||||
name: 'sammo:gateway-orchestrator',
|
||||
@@ -31,9 +32,27 @@ describe('buildPm2StartOptions', () => {
|
||||
},
|
||||
});
|
||||
expect(options.env).not.toHaveProperty('pm_id');
|
||||
expect(options.env).not.toHaveProperty('args');
|
||||
expect(options.env).not.toHaveProperty('pm_exec_path');
|
||||
expect(options.env).not.toHaveProperty('name');
|
||||
expect(options.env).not.toHaveProperty('NODE_APP_INSTANCE');
|
||||
expect(options.env).toHaveProperty('GAME_API_ROLE', 'server');
|
||||
});
|
||||
|
||||
it('keeps explicit child arguments when a PM2 parent exposes its own args in the environment', () => {
|
||||
const options = buildPm2StartOptions({
|
||||
name: 'sammo:gateway-frontend',
|
||||
script: '/srv/sammo/app/gateway-frontend/node_modules/vite/bin/vite.js',
|
||||
cwd: '/srv/sammo/app/gateway-frontend',
|
||||
args: ['preview', '--host', '0.0.0.0', '--port', '15000'],
|
||||
env: {
|
||||
args: 'daemon',
|
||||
name: 'sammo:release-controller',
|
||||
pm_id: '3',
|
||||
},
|
||||
});
|
||||
|
||||
expect(options.args).toEqual(['preview', '--host', '0.0.0.0', '--port', '15000']);
|
||||
expect(options.env).not.toHaveProperty('args');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user