run / entrypoint.js
Atharvsinh's picture
Create entrypoint.js
7f9410f verified
Raw
History Blame Contribute Delete
702 Bytes
const { ensureSqliteRuntime, buildEnvWithRuntime } = require('/usr/local/lib/node_modules/9router/hooks/sqliteRuntime');
try { ensureSqliteRuntime({ silent: false }); } catch (e) { console.error('SQLite runtime init error:', e.message); }
const { spawn } = require('child_process');
const env = buildEnvWithRuntime(process.env);
const child = spawn(process.execPath,
['--max-old-space-size=4096', '/usr/local/lib/node_modules/9router/app/custom-server.js'],
{ stdio: 'inherit', env }
);
const shutdown = () => { child.kill('SIGTERM'); setTimeout(() => process.exit(0), 2000); };
process.on('SIGTERM', shutdown);
process.on('SIGINT', shutdown);
child.on('exit', (code) => process.exit(code || 0));