fix: fix kill handler usage in examples
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 15 Aug 2023 18:07:49 +0000 (20:07 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 15 Aug 2023 18:07:49 +0000 (20:07 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts
examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts
examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts
examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts
examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts
examples/typescript/websocket-server-pool/ws-hybrid/src/websocket-server-worker.ts

index 38a4b0fafdffb8e0d3961bc715bb46dc1ca07c71..a995923928ed84ecafaf9afcbdc4ddee90884103 100644 (file)
@@ -13,6 +13,5 @@ declare module 'fastify' {
       name?: string,
       transferList?: TransferListItem[]
     ) => Promise<ThreadWorkerResponse>
-    listTaskFunctions: () => string[]
   }
 }
index 2a22fdcc6f57372a81fbe9d34ec3732deb75f0ab..6e3a1dbfec643759ef30aecfd767e5f9d1c40e02 100644 (file)
@@ -40,11 +40,6 @@ const fastifyPoolifierPlugin: FastifyPluginCallback<FastifyPoolifierOptions> = (
         await pool.execute(data, name, transferList)
     )
   }
-  if (!fastify.hasDecorator('listTaskFunctions')) {
-    fastify.decorate('listTaskFunctions', (): string[] =>
-      pool.listTaskFunctions()
-    )
-  }
   done()
 }
 
index 7a09a1ce38666ea1a0ad45e056adb4a1f89f8034..051be889250c57a97e8ea9af54e494e5c8e88a4b 100644 (file)
@@ -45,6 +45,7 @@ ClusterWorkerResponse
   public constructor () {
     super(FastifyWorker.startFastify, {
       killHandler: async () => {
+        await FastifyWorker.fastify.pool.destroy()
         await FastifyWorker.fastify.close()
       }
     })
index 0de82629cd2d369a64d7c9985746ac9cbdd1e3e9..e2ec4062820d299647132f7ac0306127e0ebe57e 100644 (file)
@@ -11,6 +11,5 @@ declare module 'fastify' {
       name?: string,
       transferList?: TransferListItem[]
     ) => Promise<WorkerResponse>
-    listTaskFunctions: () => string[]
   }
 }
index 38c808a0cc2b223239f4ad78a7fb48ad20c8b049..50668da031705190e5f7611870c51fb2f5fffc7f 100644 (file)
@@ -39,12 +39,6 @@ const fastifyPoolifierPlugin: FastifyPluginCallback<FastifyPoolifierOptions> = (
       ): Promise<WorkerResponse> => await pool.execute(data, name, transferList)
     )
   }
-  if (!fastify.hasDecorator('listTaskFunctions')) {
-    fastify.decorate('listTaskFunctions', (): string[] =>
-      pool.listTaskFunctions()
-    )
-  }
-  done()
 }
 
 export const fastifyPoolifier = fp(fastifyPoolifierPlugin, {
index 90250c040ffaac022c6b2b7c0bfea9fd28e1f226..12c2190e750d36b77a4a8aca912c62ae37711ffa 100644 (file)
@@ -95,8 +95,8 @@ ClusterWorkerResponse
   public constructor () {
     super(WebSocketServerWorker.startWebSocketServer, {
       killHandler: async () => {
-        WebSocketServerWorker.wss.close()
         await WebSocketServerWorker.requestHandlerPool.destroy()
+        WebSocketServerWorker.wss.close()
       }
     })
   }