Friday, 2 June 2017

Passing environment variables to child_process with a for loop and async.queue

Background

I'm trying to follow this blog post about how to set up multiple child process from Node JS to run R scripts using async.queue. At this point, I'm just trying to get the environment variables to work, so I'm spawning a Node script instead of R.

The Problem

When I try to adapt that post to my own needs, I have a lot of problems. My loop construct, while properly adding the variables I need to the environment, I can't seem to pass it to my worker function.

When I console.log() the environment variables after setting them, they are there. When I log them in the child process or even the worker after I pass the object, the environment variables are set only to the final "request" in my array.

I've set up an example so you can see what I mean and review my code.

What can I do to make sure all my enviornment options are passed to the queue, and that each process has a unique environment?



via nronnei

No comments:

Post a Comment