X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fhttp-server-pool%2Ffastify-hybrid%2Fsrc%2Fmain.ts;h=6b9c172792805277e23800cb8bd6571f855670fa;hb=c4a517416ff2c029d91a4ed006b94b23efb7d7a3;hp=5fc7542b7779df64a0f0aeab87ecc1ac13220246;hpb=4cc21109c903c61da22760c3799f6b7bf72f2cf2;p=poolifier.git diff --git a/examples/typescript/http-server-pool/fastify-hybrid/src/main.ts b/examples/typescript/http-server-pool/fastify-hybrid/src/main.ts index 5fc7542b..6b9c1727 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/src/main.ts +++ b/examples/typescript/http-server-pool/fastify-hybrid/src/main.ts @@ -17,12 +17,16 @@ const pool = new FixedClusterPool( Math.round(availableParallelism() / 2), fastifyWorkerFile, { + enableEvents: false, onlineHandler: () => { pool .execute({ port: 8080, workerFile: requestHandlerWorkerFile, - maxWorkers: Math.round(availableParallelism() / 4), + maxWorkers: + Math.round(availableParallelism() / 4) < 1 + ? 1 + : Math.round(availableParallelism() / 4), enableTasksQueue: true, tasksQueueOptions: { concurrency: 8 @@ -31,16 +35,15 @@ const pool = new FixedClusterPool( console.error('Thread worker error', e) } }) - .then((response) => { + .then(response => { if (response.status) { console.info( - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `Fastify is listening in cluster worker on port ${response.port}` ) } - return null + return undefined }) - .catch((error) => { + .catch(error => { console.error('Fastify failed to start in cluster worker:', error) }) },