X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fwebsocket-server-pool%2Fws-hybrid%2Fsrc%2Fmain.ts;h=0c31721a417c575c65342c41cfad5ef837e8103c;hb=a4712fbf04cdc5d6d2e4647226b1b761140dd678;hp=d9e827cbfa262f83613cb01c8201b70efdfec4a7;hpb=63ff88a9d5c789fe23036c1fed24e5d3853d2969;p=poolifier.git diff --git a/examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts b/examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts index d9e827cb..0c31721a 100644 --- a/examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts +++ b/examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts @@ -1,7 +1,7 @@ import { dirname, extname, join } from 'node:path' import { fileURLToPath } from 'node:url' import { FixedClusterPool, availableParallelism } from 'poolifier' -import { type ClusterWorkerData, type ClusterWorkerResponse } from './types.js' +import type { ClusterWorkerData, ClusterWorkerResponse } from './types.js' const webSocketServerWorkerFile = join( dirname(fileURLToPath(import.meta.url)), @@ -21,7 +21,10 @@ const pool = new FixedClusterPool( pool .execute({ port: 8080, - maxWorkers: Math.round(availableParallelism() / 2), + maxWorkers: + Math.round(availableParallelism() / 4) < 1 + ? 1 + : Math.round(availableParallelism() / 4), workerFile: requestHandlerWorkerFile, enableTasksQueue: true, tasksQueueOptions: { @@ -38,7 +41,7 @@ const pool = new FixedClusterPool( `WebSocket server is listening in cluster worker on port ${response.port}` ) } - return null + return undefined }) .catch(error => { console.error(