[nodejs] Domain for every worker?

2012-08-10 Thread Honigbaum
Hello, my node.js application uses the cluster module for forking workers and I want to use the new domain module to catch all uncaught exceptions. Is there a way to fork each worker in an own domain? I tried to wrap the whole application in an domain, but then the error handler is called for

Re: [nodejs] Domain for every worker?

2012-08-10 Thread Dan Milon
How did you implement this exactly? (gist?) You should be able to create a domain inside the slave code that will fire whenever this specific slave throws. danmilon. On 08/10/2012 03:01 PM, Honigbaum wrote: Hello, my node.js application uses the cluster module for forking workers and I

Re: [nodejs] Domain for every worker?

2012-08-10 Thread Honigbaum
Hello, I tried it like this https://gist.github.com/3313918 Or is it a problem that I assign ever domain to the same var? Torben Am Freitag, 10. August 2012 14:32:03 UTC+2 schrieb Dan Milon: How did you implement this exactly? (gist?) You should be able to create a domain inside the slave

Re: [nodejs] Domain for every worker?

2012-08-10 Thread Dan Milon
That is wrong. The domain creation should be at the code of the slave. the slaves are the actual servers that share the port. Thats where the errors occur. master is a mere coordinator. Slave code is at the else part of cluster.isMaster. Also you create the server without regard of weather

Re: [nodejs] Domain for every worker?

2012-08-10 Thread Honigbaum
Ah, you're right. You mean like this https://gist.github.com/3313918 Am Freitag, 10. August 2012 15:40:04 UTC+2 schrieb Dan Milon: That is wrong. The domain creation should be at the code of the slave. the slaves are the actual servers that share the port. Thats where the errors occur.

Re: [nodejs] Domain for every worker?

2012-08-10 Thread Dan Milon
Almost correct. But you have to add the 'error' listener before the .run call. .run will immediately call the provided function, so if an error happens immediately, you wont catch it. source: Domain.prototype.run = function(fn) { return this.bind(fn)(); }; bind here refers to the

Re: [nodejs] Domain for every worker?

2012-08-10 Thread Honigbaum
Thank you! I've refactored my code. Does anyone know if it is possible to render an error page with express, when an uncaught error is catched by the error listener of the domain? Am Freitag, 10. August 2012 16:48:17 UTC+2 schrieb Dan Milon: Almost correct. But you have to add the

Re: [nodejs] Domain for every worker?

2012-08-10 Thread Honigbaum
Thank you! I've refactored my code. Does anyone know if it is possible to render an error page with express, when an uncaught error is catched by the error listener of the domain? Or is it necessary to create a separate domain for ever request? Torben Am Freitag, 10. August 2012 16:48:17