Running bash script with "spawn" in Node.js seems to pause halfway through execution -


heres gist of i'm doing: https://gist.github.com/mattcollins84/75f9ebd422ed6d1d5c91

as part of process generate bash script has bunch of curl commands in (around 20k commands). want run script via node.

i using spawn this, , works fine. except after 70 or commands, stops. readstream created spawn stops outputting data. there no errors, or far can see.

if "ps x | grep curl" see happening, can see process id changing @ first, seems halt @ point , never starts again. process hangs. manually killing process doesn't let next 1 begin. also, process relates bash script still present, again, killing makes no difference.

observations , things i've ruled out:

  • using minimal resources
  • running generated bash script on terminal works fine
  • doesn't seem matter url curling (i.e. it's not application)

i feel there daft missing, didn't know google figure out!

i hoping run file if on terminal, appears node places kind of restriction stop running out of control. or something.

any ideas?! thanks

although not familiar node's spawn function, familiar unix pipes. sounds in first scenario, program ran produced output program did not read output. when pipe's buffer full, program executed block trying write it. unblocked when program reads pipe.

the solution found (stdio: 'inherit') tells function run child process same stdout, stderr, , stdin streams. program doesn't need read pipe because isn't pipe. program executed writes terminal, reads output, , doesn't block.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -