Skip to content

Commit a095272

Browse files
committed
extract shutdown in function
Signed-off-by: Matteo Collina <hello@matteocollina.com>
1 parent 11ecf85 commit a095272

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/start.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,19 @@ export async function start (client, selectedRuntime) {
6666
await server.close()
6767
}
6868

69-
process.once('SIGINT', async () => {
70-
process.on('SIGINT', () => {
71-
// we ignore future signals to avoid double shutdown
72-
})
69+
async function recordAndShutdown () {
70+
console.log('SIGINT received, recording metrics and shutting down...')
7371
clearTimeout(recordTimeout)
7472
await recordMetrics(entrypointUrl)
7573
await shutdown()
7674
process.removeAllListeners('SIGINT')
75+
}
76+
77+
process.once('SIGINT', () => {
78+
process.on('SIGINT', () => {
79+
// we ignore future signals to avoid double shutdown
80+
})
81+
recordAndShutdown()
7782
})
7883

7984
const { statusCode, body } = await requestRecord('start')

0 commit comments

Comments
 (0)