|
@@ -210,8 +210,8 @@ func InitInfo() {
|
|
|
// GetCodeBaseInfo 准备爬虫基本信息
|
|
|
func GetCodeBaseInfo() {
|
|
|
defer qu.Catch()
|
|
|
- sess := util.MgoE.GetMgoConn()
|
|
|
- defer util.MgoE.DestoryMongoConn(sess)
|
|
|
+ sess := util.MgoEB.GetMgoConn()
|
|
|
+ defer util.MgoEB.DestoryMongoConn(sess)
|
|
|
lock := &sync.Mutex{}
|
|
|
wg := &sync.WaitGroup{}
|
|
|
ch := make(chan bool, 5)
|
|
@@ -256,9 +256,9 @@ func GetCodeBaseInfo() {
|
|
|
"frequencyerrtimes": 1,
|
|
|
"code": 1,
|
|
|
}
|
|
|
- count := util.MgoE.Count("luaconfig", query)
|
|
|
+ count := util.MgoEB.Count("luaconfig", query)
|
|
|
logger.Debug("共加载线上爬虫个数:", count)
|
|
|
- it := sess.DB(util.MgoE.DbName).C("luaconfig").Find(&query).Select(&fieles).Iter()
|
|
|
+ it := sess.DB(util.MgoEB.DbName).C("luaconfig").Find(&query).Select(&fieles).Iter()
|
|
|
n := 0
|
|
|
for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
|
|
|
wg.Add(1)
|
|
@@ -1738,7 +1738,7 @@ func CreateTask(t *Task, sp *Spider, upsertBulk *[][]map[string]interface{}, loc
|
|
|
return
|
|
|
} else { //挂起状态有下载量,更新爬虫挂起状态
|
|
|
sp.PendState = 0 //影响任务i_pendstate状态
|
|
|
- util.MgoE.Update("luaconfig", map[string]interface{}{"code": sp.Code}, map[string]interface{}{"$set": map[string]interface{}{"pendstate": 0}}, false, false)
|
|
|
+ util.MgoEB.Update("luaconfig", map[string]interface{}{"code": sp.Code}, map[string]interface{}{"$set": map[string]interface{}{"pendstate": 0}}, false, false)
|
|
|
}
|
|
|
}
|
|
|
diff := time.Now().Unix() - sp.AuditTime
|
|
@@ -1865,7 +1865,7 @@ func UpdateLuaInfo(sp *Spider) {
|
|
|
set["param_common.5"] = sp.MaxPage + 1
|
|
|
}
|
|
|
logger.Debug("Code:", sp.Code, " ", sp.FrequencyErrTimes)
|
|
|
- b := util.MgoE.Update("luaconfig", map[string]interface{}{"code": sp.Code}, map[string]interface{}{"$set": set}, false, false)
|
|
|
+ b := util.MgoEB.Update("luaconfig", map[string]interface{}{"code": sp.Code}, map[string]interface{}{"$set": set}, false, false)
|
|
|
if b && sp.FrequencyErrTimes <= 3 { //FrequencyErrTimes>3时会建采集频率异常的待处理任务,不再上下架
|
|
|
//爬虫下架、上加
|
|
|
qu.Debug("爬虫上下架 code:", sp.Code)
|