fix(api): delay pm2 start until server has booted

prior to this, pm2 would mark unraid-api as started as soon as the
node process started. The Nest server wouldn't finish booting until
later. This meant unraid-api could "start", but the webgui wouldn't be
fully functional because it couldn't connect to the api yet. This was a
sucky user & dev experience.
This commit is contained in:
Pujit Mehrotra
2025-01-12 14:12:32 -05:00
committed by Pujit Mehrotra
parent 2327b00d30
commit 3c27b51ab8
2 changed files with 5 additions and 1 deletions

View File

@@ -7,6 +7,8 @@
"cwd": "/usr/local/unraid-api",
"log": "/var/log/unraid-api/unraid-api.log",
"exec_mode": "fork",
"wait_ready": true,
"listen_timeout": 30000,
"ignore_watch": [
"node_modules",
"src",

View File

@@ -48,7 +48,9 @@ export async function bootstrapNestServer(): Promise<NestFastifyApplication> {
const result = await server.listen({ port: parseInt(PORT), host: '0.0.0.0' });
console.log('Server listening on %s', result);
}
if (process.send) {
process.send('ready');
}
apiLogger.info('Nest Server is now listening');
return app;