X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fhttp-server-pool%2Ffastify-cluster%2Fsrc%2Fworker.ts;h=283a223e3438aa07af36343368d6dd03de05017e;hb=8ccfa7d88f7fcfa93b1e826f31cc92d7bf288e80;hp=3f7b3661f99cd2f51082366eadfc8cbe17ba804a;hpb=8ebe6c308dc1fc3202980126da043b2855d24780;p=poolifier.git diff --git a/examples/typescript/http-server-pool/fastify-cluster/src/worker.ts b/examples/typescript/http-server-pool/fastify-cluster/src/worker.ts index 3f7b3661..283a223e 100644 --- a/examples/typescript/http-server-pool/fastify-cluster/src/worker.ts +++ b/examples/typescript/http-server-pool/fastify-cluster/src/worker.ts @@ -17,6 +17,7 @@ class FastifyWorker extends ClusterWorker { workerData?: WorkerData ): Promise => { const { port } = workerData as WorkerData + FastifyWorker.fastify = Fastify({ logger: true }) @@ -35,12 +36,16 @@ class FastifyWorker extends ClusterWorker { await FastifyWorker.fastify.listen({ port }) return { status: true, - port: (FastifyWorker.fastify.server.address() as AddressInfo).port + port: (FastifyWorker.fastify.server.address() as AddressInfo)?.port } } public constructor () { - super(FastifyWorker.startFastify) + super(FastifyWorker.startFastify, { + killHandler: async () => { + await FastifyWorker.fastify.close() + } + }) } }