mdlawson / piping

Keep your code piping hot! Live code reloading without additional binaries
MIT License
219 stars 13 forks source link

Added an option to pass environment variables to the workers #18

Open leops opened 8 years ago

leops commented 8 years ago

This PR adds a new env option, a simple key-value object to be passed to cluster.fork() in order to inject additional environment variables into the workers.

mdlawson commented 8 years ago

I'm open to adding this, but can I ask what the use case for this is? Any environment variables set on the process should be passed through to the forked version, and seeing as piping is intended to be pretty transparent I'm not sure what the benefit is.

leops commented 8 years ago

In our project, we use this option to pass specific configuration options to the server instance in a development environment.

mdlawson commented 8 years ago

I've added this to 1.0.0-rc.2, which is an ES6 rewrite of piping. Could you check everything is working for you there?

leops commented 8 years ago

It's working but I had to add to set the throw option to false, otherwise it simply crashes. Did I miss something there ?

mdlawson commented 8 years ago

The idea behind the throw option is to "crash" the initial process to prevent application code from executing on it, but an uncaught exception handler should mean the process doesn't actually exit. Is it possible that piping is required within some environment which contains a try/catch block which would mess with that concept?

An example showing the crashing would be great, it worked fine in my testing, though is regrettably not amiable to testing in general. I may disable it by default if it usually causes issues.