[英]Node.js child process exits with SIGTERM
我正在使用 Node 6.9 生成一個子進程。
const child = require('child_process').execFile('command', args);
child.stdout.on('data', (data) => {
console.log('child:', data);
});
child.stderr.on('data', (data) => {
console.log('child:', data);
});
child.on('close', (code, signal) => {
console.log(`ERROR: child terminated. Exit code: ${code}, signal: ${signal}`);
});
我的子進程運行了約 1m 30 秒,但隨后我從我的 Node.js 程序中獲得了以下輸出:
ERROR: child terminated. Exit code: null, signal: SIGTERM
什么終止了我的子進程,為什么?
編輯:我添加了 killSignal: 'SIGILL' 作為選項。
var child = require('child_process').execFile('geth', args, { killSignal: 'SIGILL'});
現在,我明白了:
ERROR: go-ethereum terminated. Exit code: 2, signal: null
我找到了問題和解決方案。
maxBuffer 在 stdout 或 stderr 上允許的最大數據量(以字節為單位) - 如果超過,則殺死子進程(默認值:200*1024)
我可以將maxBuffer
選項設置得更高。
childProcess.execFile('geth', args, { maxBuffer: 400 * 1024});
似乎您無法禁用maxBuffer
選項,即使將其設置為 0 也不行。但這似乎是故意的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.