Spawning process with arguments in node.js

前端 未结 1 774
陌清茗
陌清茗 2021-01-07 18:24

I need to spawn a child process from node.js, whilst using ulimit to keep it from using to much memory.

Following the docs, it wasn\'t hard

1条回答
  •  伪装坚强ぢ
    2021-01-07 18:40

    Those are two different commands. Don't club them if you are using spawn. Use separate child processes.

     child1 = spawn('ulimit', ['-m', '65536']);
     child2 = spawn('coffee', ['app.coffee']);
    

    If you are not interested in output stream(if you want just buffered output) you can use exec.

    var exec = require('child_process').exec,
    child;
    
    child = exec('ulimit -m 65536; coffee app.coffee',
      function (error, stdout, stderr) {
        console.log('stdout: ' + stdout);
      }
    });
    

    0 讨论(0)
提交回复
热议问题