Start server when loaded by the PM2 fork container

This commit is contained in:
2026-10-09 17:56:37 +09:00
parent f09b661ac0
commit 736da09846
3 changed files with 17 additions and 3 deletions
+11
View File
@@ -38,6 +38,17 @@ test('operational CLI entrypoints exist without starting an HTTP listener', () =
for (const script of ['metrics', 'backup']) assert.ok(existsSync(resolve(`server/${script}.mjs`)), `missing ${script} CLI`);
});
test('PM2 fork imports execute the server entrypoint instead of silently skipping startup', () => {
const output = spawnSync(process.execPath, ['--input-type=module', '-e',
"import { pathToFileURL } from 'node:url'; process.argv[1] = 'ProcessContainerFork.js'; await import(pathToFileURL(process.env.pm_exec_path).href);",
], {
env: { ...process.env, DB_PATH: '', NODE_ENV: 'production', pm_exec_path: resolve('server/index.mjs') },
encoding: 'utf8',
});
assert.equal(output.status, 1, 'the entrypoint must attempt startup and reject the missing database configuration');
assert.match(output.stderr, /Server startup failed/);
});
test('metrics prints aggregate-only JSON from an existing read-only database', async t => {
const { store, dbPath } = await setup(t);
const output = cli('metrics', ['--month', '2026-10'], dbPath);