javascript - increase maximum byte size of nodejs pipe -


i'm trying write little commander script proxies other scripts in project , i'm trying use node pipe stdout spawned process current process's stdout:

function runcommand(command, arguments) {     var commandprocess = childprocess.spawn(command, arguments);     commandprocess.stdout.pipe(process.stdout);     commandprocess.on("exit", process.exit); } 

this works fine until start getting large output sub processes (for example 1 of them maven command). i'm seeing prints out first 8192 bytes of stdout , stores rest until next "data" event. prints out next 8192 etc. means there's lag in output , @ times when we're running server process stops printing things out until trigger on server triggers "data" event.

is there way increase size of buffer or avoid behavior? ideally commander script proxies our other scripts , should print out is.

you using node process spawn asynchronously asynchronous give output when child process gives stdout. ref: [https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options][1]

i recommend use child process exec run process can control size of output buffer, give output after child process finished.this how pass buffer size

var execute = function(command, callback){     exec(command, {maxbuffer: 1024 * 500}, function(error, stdout, stderr){ callback(error, stdout); }); }; 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -