1 Star 0 Fork 255

nature / neocrawler

forked from Cherokee / neocrawler 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
crawler.js 740 Bytes
一键复制 编辑 原始数据 按行查看 历史
waterbear 提交于 2014-03-26 09:44 . fix spawn bug
/**
* Created by cherokee on 14-3-25.
*/
var retryTimes = 0;
var spawnIt = function(tryTimes){
var spawn = require('child_process').spawn;
var runner = spawn('node',['run.js'].concat(process.argv));
runner.stdout.on('data', function (data) {
console.log(data.toString('utf8'));
});
runner.stderr.on('data', function (data) {
console.log(data.toString('utf8'));
});
runner.on('exit', function (code, signal) {
console.log('Child process exit :' + code+', '+signal);
if(code!==0&&tryTimes<500){
console.log('Restart, times: '+(tryTimes++));
process.nextTick(function(){spawnIt(tryTimes)});
spawn = null;
}
});
}
spawnIt(0);
1
https://gitee.com/naturewinder/neocrawler.git
git@gitee.com:naturewinder/neocrawler.git
naturewinder
neocrawler
neocrawler
master

搜索帮助