var cahce_seek_index = CONFIG.cache_key.log_read_end + seek_index;
redis.get(cahce_seek_index).then(function (data) {
//标识位不存在或者比现在文件大小字节数还大的,都认为从新文件第一行开始读取
console.log(data);
if (data == null || data > end_Bytes) {
start_Bytes = 0;
} else {
start_Bytes = data;
}
//将stream流给readLine流处理
var objReadline = readLine.createInterface({
input: fs.createReadStream(log_path, {start: parseInt(start_Bytes)})
});
objReadline.on('line', function (line) {
var tmp = 'line' + index.toString() + ':' + line;
console.log(index, line);
index++;
});
objReadline.on('close', function () {
// redis.set(cahce_seek_index, end_Bytes);
console.log('此次任务解析行数:' + index);
process.exit();
});
});
比如文件有10万行,每次读取到5000行左右就会退出,而且并没有执行close事件,是什么问题导致的呢