From: Jérôme Benoit Date: Tue, 15 Aug 2023 18:07:49 +0000 (+0200) Subject: fix: fix kill handler usage in examples X-Git-Tag: v2.6.27~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=93b097acefb8dfea7259bff4cb9f6c337d34db94;p=poolifier.git fix: fix kill handler usage in examples Signed-off-by: Jérôme Benoit --- diff --git a/examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts b/examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts index 38a4b0fa..a9959239 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts +++ b/examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts @@ -13,6 +13,5 @@ declare module 'fastify' { name?: string, transferList?: TransferListItem[] ) => Promise - listTaskFunctions: () => string[] } } diff --git a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts index 2a22fdcc..6e3a1dbf 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts +++ b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts @@ -40,11 +40,6 @@ const fastifyPoolifierPlugin: FastifyPluginCallback = ( await pool.execute(data, name, transferList) ) } - if (!fastify.hasDecorator('listTaskFunctions')) { - fastify.decorate('listTaskFunctions', (): string[] => - pool.listTaskFunctions() - ) - } done() } diff --git a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts index 7a09a1ce..051be889 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts +++ b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts @@ -45,6 +45,7 @@ ClusterWorkerResponse public constructor () { super(FastifyWorker.startFastify, { killHandler: async () => { + await FastifyWorker.fastify.pool.destroy() await FastifyWorker.fastify.close() } }) diff --git a/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts b/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts index 0de82629..e2ec4062 100644 --- a/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts +++ b/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts @@ -11,6 +11,5 @@ declare module 'fastify' { name?: string, transferList?: TransferListItem[] ) => Promise - listTaskFunctions: () => string[] } } diff --git a/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts b/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts index 38c808a0..50668da0 100644 --- a/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts +++ b/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts @@ -39,12 +39,6 @@ const fastifyPoolifierPlugin: FastifyPluginCallback = ( ): Promise => await pool.execute(data, name, transferList) ) } - if (!fastify.hasDecorator('listTaskFunctions')) { - fastify.decorate('listTaskFunctions', (): string[] => - pool.listTaskFunctions() - ) - } - done() } export const fastifyPoolifier = fp(fastifyPoolifierPlugin, { diff --git a/examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts b/examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts index 90250c04..12c2190e 100644 --- a/examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts +++ b/examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts @@ -95,8 +95,8 @@ ClusterWorkerResponse public constructor () { super(WebSocketServerWorker.startWebSocketServer, { killHandler: async () => { - WebSocketServerWorker.wss.close() await WebSocketServerWorker.requestHandlerPool.destroy() + WebSocketServerWorker.wss.close() } }) }