X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=examples%2Ftypescript%2Fwebsocket-server-pool%2Fws-hybrid%2Fsrc%2Fmain.ts;h=3adac7e819b3c6a35fd5fbd6f40196ea1df2846b;hb=cf02ff9e146e22a2f99a6af35de7ce49efd4c6b5;hp=62e772da7bf34d4f808ef56e037f814dea16fc46;hpb=8ad621cc1d32ed396fca3ef2ec48337e42d2dcc2;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 62e772da..3adac7e8 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: { @@ -31,7 +34,7 @@ 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 @@ -40,7 +43,7 @@ const pool = new FixedClusterPool( } return null }) - .catch((error) => { + .catch(error => { console.error( 'WebSocket server failed to start in cluster worker:', error