Skip to content

Commit 6bc02ac

Browse files
committed
fix: log more on shutdown
1 parent 2cf55a7 commit 6bc02ac

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/express-app/app.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,26 @@ export async function startApp<
5454
});
5555
const logger = shouldPrettyPrint
5656
? pino(
57-
{
58-
transport: {
59-
target: 'pino-pretty',
60-
options: {
61-
colorize: true,
62-
},
57+
{
58+
transport: {
59+
target: 'pino-pretty',
60+
options: {
61+
colorize: true,
6362
},
6463
},
65-
destination,
66-
)
64+
},
65+
destination,
66+
)
6767
: pino(
68-
{
69-
formatters: {
70-
level(label) {
71-
return { level: label };
72-
},
68+
{
69+
formatters: {
70+
level(label) {
71+
return { level: label };
7372
},
7473
},
75-
destination,
76-
);
74+
},
75+
destination,
76+
);
7777

7878
const serviceImpl = service();
7979
assert(serviceImpl?.start, 'Service function did not return a conforming object');
@@ -320,13 +320,15 @@ export async function listen<SLocals extends AnyServiceLocals = ServiceLocals<Co
320320
}
321321
logger.info('Graceful shutdown beginning');
322322
return new Promise((accept) => {
323+
// Per docs https://www.npmjs.com/package/@godaddy/terminus in Kubernetes, wait for readiness threshold
323324
setTimeout(accept, 10000);
324325
});
325326
},
326327
onShutdown() {
327328
return Promise.resolve()
328329
.then(() => service.stop?.(app))
329-
.then(shutdownHandler || Promise.resolve)
330+
.then(() => { logger.info('Service stop complete'); })
331+
.then(shutdownHandler || (() => Promise.resolve()))
330332
.then(() => logger.info('Graceful shutdown complete'))
331333
.catch((error) => logger.error(error, 'Error terminating tracing'))
332334
.then(() => (logger as pino.Logger).flush?.());

0 commit comments

Comments
 (0)