X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fhttp-server-pool%2Ffastify-worker_threads%2Fsrc%2Fmain.ts;h=b9aba792c05a8e2459eecfac5a93457a4185da9a;hb=bbe3fa62e097229db829372144cec8475a44fdc3;hp=7db0b5196d973b98b51e6ac37dea5d12af9bbbf1;hpb=d2bc8d8026164b1389822feced0f42af20552176;p=poolifier.git diff --git a/examples/typescript/http-server-pool/fastify-worker_threads/src/main.ts b/examples/typescript/http-server-pool/fastify-worker_threads/src/main.ts index 7db0b519..b9aba792 100644 --- a/examples/typescript/http-server-pool/fastify-worker_threads/src/main.ts +++ b/examples/typescript/http-server-pool/fastify-worker_threads/src/main.ts @@ -1,6 +1,9 @@ import { dirname, extname, join } from 'node:path' +import { exit } from 'node:process' import { fileURLToPath } from 'node:url' + import Fastify from 'fastify' + import { fastifyPoolifier } from './fastify-poolifier.js' /** @@ -9,11 +12,12 @@ import { fastifyPoolifier } from './fastify-poolifier.js' const port = 8080 const fastify = Fastify({ - logger: true + logger: true, }) const workerFile = join( dirname(fileURLToPath(import.meta.url)), + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `worker${extname(fileURLToPath(import.meta.url))}` ) @@ -21,11 +25,11 @@ await fastify.register(fastifyPoolifier, { workerFile, enableTasksQueue: true, tasksQueueOptions: { - concurrency: 8 + concurrency: 8, }, errorHandler: (e: Error) => { - fastify.log.error(e) - } + fastify.log.error('Thread worker error:', e) + }, }) fastify.all('/api/echo', async request => { @@ -43,5 +47,5 @@ try { await fastify.listen({ port }) } catch (err) { fastify.log.error(err) - process.exit(1) + exit(1) }