diff --git a/README.md b/README.md index df8575a9..1e588b26 100644 --- a/README.md +++ b/README.md @@ -218,18 +218,13 @@ const appService = require('./app.js') app.register(appService) // delay is the number of milliseconds for the graceful close to finish -const closeListeners = closeWithGrace({ delay: process.env.FASTIFY_CLOSE_GRACE_DELAY || 500 }, async function ({ signal, err, manual }) { +closeWithGrace({ delay: process.env.FASTIFY_CLOSE_GRACE_DELAY || 500 }, async function ({ signal, err, manual }) { if (err) { app.log.error(err) } await app.close() }) -app.addHook('onClose', (instance, done) => { - closeListeners.uninstall() - done() -}) - // Start listening. app.listen({ port: process.env.PORT || 3000 }, (err) => { if (err) { diff --git a/templates/eject-esm/server.js b/templates/eject-esm/server.js index 42c4ae9e..3001fa62 100644 --- a/templates/eject-esm/server.js +++ b/templates/eject-esm/server.js @@ -22,18 +22,13 @@ const app = Fastify({ app.register(appService) // delay is the number of milliseconds for the graceful close to finish -const closeListeners = closeWithGrace({ delay: process.env.FASTIFY_CLOSE_GRACE_DELAY || 500 }, async function ({ signal, err, manual }) { +closeWithGrace({ delay: process.env.FASTIFY_CLOSE_GRACE_DELAY || 500 }, async function ({ signal, err, manual }) { if (err) { app.log.error(err) } await app.close() }) -app.addHook('onClose', (instance, done) => { - closeListeners.uninstall() - done() -}) - // Start listening. app.listen({ port: process.env.PORT || 3000 }, (err) => { if (err) { diff --git a/templates/eject-ts/server.ts b/templates/eject-ts/server.ts index 802c4de8..d2ea5071 100644 --- a/templates/eject-ts/server.ts +++ b/templates/eject-ts/server.ts @@ -17,18 +17,13 @@ const app = Fastify({ app.register(import("./app")); // delay is the number of milliseconds for the graceful close to finish -const closeListeners = closeWithGrace({ delay: parseInt(process.env.FASTIFY_CLOSE_GRACE_DELAY) || 500 }, async function ({ signal, err, manual }) { +closeWithGrace({ delay: parseInt(process.env.FASTIFY_CLOSE_GRACE_DELAY) || 500 }, async function ({ signal, err, manual }) { if (err) { app.log.error(err) } await app.close() } as closeWithGrace.CloseWithGraceAsyncCallback) -app.addHook('onClose', (instance, done) => { - closeListeners.uninstall() - done() -}) - // Start listening. app.listen({ port: parseInt(process.env.PORT) || 3000 }, (err: any) => { if (err) { diff --git a/templates/eject/server.js b/templates/eject/server.js index 66795190..eb96a0e0 100644 --- a/templates/eject/server.js +++ b/templates/eject/server.js @@ -19,18 +19,13 @@ const appService = require('./app.js') app.register(appService) // delay is the number of milliseconds for the graceful close to finish -const closeListeners = closeWithGrace({ delay: process.env.FASTIFY_CLOSE_GRACE_DELAY || 500 }, async function ({ signal, err, manual }) { +closeWithGrace({ delay: process.env.FASTIFY_CLOSE_GRACE_DELAY || 500 }, async function ({ signal, err, manual }) { if (err) { app.log.error(err) } await app.close() }) -app.addHook('onClose', (instance, done) => { - closeListeners.uninstall() - done() -}) - // Start listening. app.listen({ port: process.env.PORT || 3000 }, (err) => { if (err) {