From: Jérôme Benoit Date: Sat, 30 Mar 2024 20:34:39 +0000 (+0100) Subject: fix(examples): fix express cluster worker error at startup X-Git-Tag: v3.1.28~11 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b7172bc04e803e849ba215e368cb32e788febcb4;p=poolifier.git fix(examples): fix express cluster worker error at startup Signed-off-by: Jérôme Benoit --- diff --git a/examples/typescript/http-server-pool/express-cluster/src/worker.ts b/examples/typescript/http-server-pool/express-cluster/src/worker.ts index da2e9ad7..98ca45de 100644 --- a/examples/typescript/http-server-pool/express-cluster/src/worker.ts +++ b/examples/typescript/http-server-pool/express-cluster/src/worker.ts @@ -43,14 +43,16 @@ class ExpressWorker extends ClusterWorker { .end() }) + let listenerPort: number | undefined ExpressWorker.server = application.listen(port, () => { + listenerPort = (ExpressWorker.server.address() as AddressInfo).port console.info( - `⚡️[express server]: Express server is started in cluster worker at http://localhost:${port}/` + `⚡️[express server]: Express server is started in cluster worker at http://localhost:${listenerPort}/` ) }) return { status: true, - port: (ExpressWorker.server.address() as AddressInfo).port + port: listenerPort ?? port } } diff --git a/examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts b/examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts index 78a18d67..7ba9f374 100644 --- a/examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts +++ b/examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts @@ -70,14 +70,16 @@ ClusterWorkerResponse .catch(emptyFunction) }) + let listenerPort: number | undefined ExpressWorker.server = application.listen(port, () => { + listenerPort = (ExpressWorker.server.address() as AddressInfo).port console.info( - `⚡️[express server]: Express server is started in cluster worker at http://localhost:${port}/` + `⚡️[express server]: Express server is started in cluster worker at http://localhost:${listenerPort}/` ) }) return { status: true, - port: (ExpressWorker.server.address() as AddressInfo).port + port: listenerPort ?? port } }