express-metrics
express-metrics copied to clipboard
Server cannot handle cluster worker unhandled exception
Hi there,
Love the library as it's quite simple to use. Got question about the communication between worker & master
At the moment the communication is from worker reporting to the master via worker's process.send
and the server is listening on 'message' event. But when a process has gone south and new worker spins up. the server will not get the new message as there's no listening in the fork event on the cluster.
I'm hitting this problem right now. and I think there are two ways to solve it.
-
make the server.cluster.proxy to listen on 'fork' event and make it pick up new workers.
-
use cluster.worker.send in the client and process.on('message') on the server proxy.
feels to me the second way is more natural. Thought?
I can quickly submit a PR if you want. Let me know if you want to think more about it.
Cheers
nvm what I said about No.2, after some reading I'll just put an event handler on fork so that server can handle newly spin up workers.
Thanks for the feedback!
As you said, I'll go for option 1. I'm totally open to contributions, so I encourage you to send a PR. It'd be very nice.
To be honest, currently I don't use this library. I believe a server should not collect, aggregate and expose it own metrics. Said that, under some circumstances express-metrics
is still useful.
I'll take a look to the process messaging when a worker disconnects and a new one is forked.
Well as long as the stats port is different and not open to public. I'm ok as I'm at the moment try to come up with some stats quick to verify my idea. It's quite useful. Also the stated part is cool too.
Btw what do you use now?