repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps-dev): apply updates
[poolifier.git]
/
examples
/
typescript
/
websocket-server-pool
/
ws-hybrid
/
src
/
main.ts
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 3adac7e819b3c6a35fd5fbd6f40196ea1df2846b..400f0beed3e2a790fd8306e6f70f183f36819213 100644
(file)
--- a/
examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts
+++ b/
examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts
@@
-1,6
+1,8
@@
import { dirname, extname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { dirname, extname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
-import { FixedClusterPool, availableParallelism } from 'poolifier'
+
+import { availableParallelism, FixedClusterPool } from 'poolifier'
+
import type { ClusterWorkerData, ClusterWorkerResponse } from './types.js'
const webSocketServerWorkerFile = join(
import type { ClusterWorkerData, ClusterWorkerResponse } from './types.js'
const webSocketServerWorkerFile = join(
@@
-17,6
+19,7
@@
const pool = new FixedClusterPool<ClusterWorkerData, ClusterWorkerResponse>(
Math.round(availableParallelism() / 2),
webSocketServerWorkerFile,
{
Math.round(availableParallelism() / 2),
webSocketServerWorkerFile,
{
+ enableEvents: false,
onlineHandler: () => {
pool
.execute({
onlineHandler: () => {
pool
.execute({
@@
-28,22
+31,22
@@
const pool = new FixedClusterPool<ClusterWorkerData, ClusterWorkerResponse>(
workerFile: requestHandlerWorkerFile,
enableTasksQueue: true,
tasksQueueOptions: {
workerFile: requestHandlerWorkerFile,
enableTasksQueue: true,
tasksQueueOptions: {
- concurrency: 8
+ concurrency: 8
,
},
errorHandler: (e: Error) => {
console.error('Thread worker error:', e)
},
errorHandler: (e: Error) => {
console.error('Thread worker error:', e)
- }
+ }
,
})
.then(response => {
if (response.status) {
console.info(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
})
.then(response => {
if (response.status) {
console.info(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
- `WebSocket server is listening in cluster worker on port ${response.port}`
+ `WebSocket server is listening in cluster worker on port ${response.port
?.toString()
}`
)
}
)
}
- return
null
+ return
undefined
})
})
- .catch(
error
=> {
+ .catch(
(error: unknown)
=> {
console.error(
'WebSocket server failed to start in cluster worker:',
error
console.error(
'WebSocket server failed to start in cluster worker:',
error
@@
-52,6
+55,6
@@
const pool = new FixedClusterPool<ClusterWorkerData, ClusterWorkerResponse>(
},
errorHandler: (e: Error) => {
console.error('Cluster worker error', e)
},
errorHandler: (e: Error) => {
console.error('Cluster worker error', e)
- }
+ }
,
}
)
}
)