我遇到了一些child_process分叉的问题,我想这就像stdio。分叉的子进程挂在node.js
当我通过一些js代码fork之后,子进程请求流数据然后接收数据,只是通过数据到父进程。 当我在日志“Count [1503]”停止后向儿童添加日志时。 (我不知道你的情况也1499,但却完全相同的数据manytimes你试试)
我只是做以下 示例代码(EXCUTE test.js)
// test.js
var express = require('express'),
app = express(),
child_process = require('child_process');
app.listen(3030, function() {
console.log('service started');
});
var child = child_process.fork(__dirname + '/test_child.js', [], { silent: true });
child.on('exit', function(code, signal) {
console.log('exit\n', code, signal);
})
// test_child.js
var winston = require('winston'),
logger = new winston.Logger({
level: 'silly',
transports: [
new (winston.transports.File)({
name: 'mainLog',
filename: 'child_test.log',
level: 'silly'
}),
new (winston.transports.Console)({
colorize: true,
})
]
});
var interval = 2,
cnt = 1,
count = 1;
setInterval(function() {
logger.info('Count[%d]', count++);
}, interval)
setInterval(function() {
logger.info('CNT[%d]', cnt++);
}, interval)
的原因,我想这是关于标准输入输出相关的缓冲区,当我添加一些文本日志,日志计数是要做空。
请帮助我,谁知道node.js的
感谢提前。
非常感谢你!我没有找到刷新流缓冲区,即使我猜测流缓冲区。 – user1971888