Open leops opened 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.
In our project, we use this option to pass specific configuration options to the server instance in a development environment.
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?
It's working but I had to add to set the throw
option to false, otherwise it simply crashes. Did I miss something there ?
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.
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.