|
@@ -1080,6 +1080,7 @@ func (f *Front) Assign() {
|
|
|
"claimtype": CLAIMTYPECLAIMED,
|
|
|
"claimtime": now,
|
|
|
"recovertime": recovertime,
|
|
|
+ "expiretime": recovertime,
|
|
|
"createuseremail": (*user)["s_email"],
|
|
|
"createuser": name,
|
|
|
"createuserid": userid,
|
|
@@ -1087,7 +1088,7 @@ func (f *Front) Assign() {
|
|
|
"modifyuserid": userid,
|
|
|
//"platform": platform,
|
|
|
}
|
|
|
- if claimtype == CLAIMTYPECLAIMED { //已认领的爬虫增加回收日志
|
|
|
+ if claimtype >= CLAIMTYPECLAIMED { //已认领的爬虫增加回收日志
|
|
|
//回收日志
|
|
|
recovelog := map[string]interface{}{
|
|
|
"site": l["site"],
|
|
@@ -1119,6 +1120,7 @@ func (f *Front) Assign() {
|
|
|
"comeintime": now,
|
|
|
"claimtime": now,
|
|
|
"recovertime": recovertime,
|
|
|
+ "expiretime": recovertime,
|
|
|
"returntime": int64(0),
|
|
|
"important": spiderimportant,
|
|
|
"returnreason": "",
|
|
@@ -1176,11 +1178,11 @@ func (f *Front) SpiderUpdatePlatform() {
|
|
|
b = u.MgoS.Update("spider_heart", map[string]interface{}{"code": code}, map[string]interface{}{"$set": map[string]interface{}{"del": true}}, false, true)
|
|
|
pf := qu.ObjToString(l["platform"])
|
|
|
if pf == "golua平台" || pf == "chrome" { //爬虫所属golua平台
|
|
|
- b, err = spider.UpdateSpiderByCodeState(code, "6", qu.IntAll(l["event"])) //下架
|
|
|
+ b, err = spider.UpdateSpiderByCodeState(code, "6", qu.IntAll(l["event"]), false) //下架
|
|
|
if b && err == nil {
|
|
|
//历史节点下架为了避免线上运行爬虫待完成时改为7000采集历史,但是又转到其他平台,导致原线上运行节点爬虫并未下线,心跳异常
|
|
|
if incrementevent := l["incrementevent"]; incrementevent != nil {
|
|
|
- b, err = spider.UpdateSpiderByCodeState(code, "6", qu.IntAll(incrementevent))
|
|
|
+ b, err = spider.UpdateSpiderByCodeState(code, "6", qu.IntAll(incrementevent), false)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1199,26 +1201,29 @@ func (f *Front) SpiderUpdatePlatform() {
|
|
|
set["claimtype"] = CLAIMTYPEUNCLAIMED
|
|
|
set["claimtime"] = int64(0)
|
|
|
set["recovertime"] = int64(0)
|
|
|
- //换平台爬虫回收,保存日志
|
|
|
- recovelog := map[string]interface{}{
|
|
|
- "site": l["site"],
|
|
|
- "code": l["code"],
|
|
|
- "channel": l["channel"],
|
|
|
- "modifyuser": l["modifyuser"],
|
|
|
- "priority": l["priority"],
|
|
|
- "stype": "回收",
|
|
|
- "comeintime": time.Now().Unix(),
|
|
|
- "claimtime": l["claimtime"],
|
|
|
- "recovertime": l["recovertime"],
|
|
|
- "returntime": int64(0),
|
|
|
- "important": l["spiderimportant"],
|
|
|
- "returnreason": "转平台",
|
|
|
- "claimrecovertype": 0,
|
|
|
- "source": "爬虫转平台回收",
|
|
|
+ if qu.IntAll(l["claimtype"]) > CLAIMTYPEUNCLAIMED {
|
|
|
+ //换平台爬虫回收,保存日志
|
|
|
+ recovelog := map[string]interface{}{
|
|
|
+ "site": l["site"],
|
|
|
+ "code": l["code"],
|
|
|
+ "channel": l["channel"],
|
|
|
+ "modifyuser": l["modifyuser"],
|
|
|
+ "priority": l["priority"],
|
|
|
+ "stype": "回收",
|
|
|
+ "comeintime": time.Now().Unix(),
|
|
|
+ "claimtime": l["claimtime"],
|
|
|
+ "recovertime": l["recovertime"],
|
|
|
+ "expiretime": l["expiretime"],
|
|
|
+ "returntime": int64(0),
|
|
|
+ "important": l["spiderimportant"],
|
|
|
+ "returnreason": "转平台",
|
|
|
+ "claimrecovertype": 0,
|
|
|
+ "source": "爬虫转平台回收",
|
|
|
+ }
|
|
|
+ save = append(save, recovelog)
|
|
|
}
|
|
|
- save = append(save, recovelog)
|
|
|
- update = append(update, map[string]interface{}{"$set": set})
|
|
|
arr = append(arr, update)
|
|
|
+ update = append(update, map[string]interface{}{"$set": set})
|
|
|
}
|
|
|
u.MgoEB.UpdateBulk("luaconfig", arr...)
|
|
|
if len(save) > 0 {
|
|
@@ -1421,11 +1426,11 @@ func (f *Front) UpdateESP() {
|
|
|
var err error
|
|
|
pf := qu.ObjToString((*one)["platform"])
|
|
|
if pf == "golua平台" || pf == "chrome" { //爬虫原平台所属golua平台,进行下架
|
|
|
- b, err = spider.UpdateSpiderByCodeState(code, "6", qu.IntAll((*one)["event"])) //下架
|
|
|
+ b, err = spider.UpdateSpiderByCodeState(code, "6", qu.IntAll((*one)["event"]), false) //下架
|
|
|
if b && err == nil {
|
|
|
//历史节点下架为了避免线上运行爬虫待完成时改为7000采集历史,但是又转到其他平台,导致原线上运行节点爬虫并未下线,心跳异常
|
|
|
if incrementevent := (*one)["incrementevent"]; incrementevent != nil {
|
|
|
- b, err = spider.UpdateSpiderByCodeState(code, "6", qu.IntAll(incrementevent))
|
|
|
+ b, err = spider.UpdateSpiderByCodeState(code, "6", qu.IntAll(incrementevent), false)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1442,24 +1447,28 @@ func (f *Front) UpdateESP() {
|
|
|
set["claimtype"] = CLAIMTYPEUNCLAIMED
|
|
|
set["claimtime"] = int64(0)
|
|
|
set["recovertime"] = int64(0)
|
|
|
- //换平台爬虫回收,保存日志
|
|
|
- recovelog := map[string]interface{}{
|
|
|
- "site": (*one)["site"],
|
|
|
- "code": (*one)["code"],
|
|
|
- "channel": (*one)["channel"],
|
|
|
- "modifyuser": (*one)["modifyuser"],
|
|
|
- "priority": (*one)["priority"],
|
|
|
- "stype": "回收",
|
|
|
- "comeintime": time.Now().Unix(),
|
|
|
- "claimtime": (*one)["claimtime"],
|
|
|
- "recovertime": (*one)["recovertime"],
|
|
|
- "returntime": int64(0),
|
|
|
- "important": (*one)["spiderimportant"],
|
|
|
- "returnreason": "转平台",
|
|
|
- "claimrecovertype": 0,
|
|
|
- "source": "爬虫转平台回收",
|
|
|
+ //已被认领的爬虫回收
|
|
|
+ if qu.IntAll((*one)["claimtype"]) > CLAIMTYPEUNCLAIMED {
|
|
|
+ //换平台爬虫回收,保存日志
|
|
|
+ recovelog := map[string]interface{}{
|
|
|
+ "site": (*one)["site"],
|
|
|
+ "code": (*one)["code"],
|
|
|
+ "channel": (*one)["channel"],
|
|
|
+ "modifyuser": (*one)["modifyuser"],
|
|
|
+ "priority": (*one)["priority"],
|
|
|
+ "stype": "回收",
|
|
|
+ "comeintime": time.Now().Unix(),
|
|
|
+ "claimtime": (*one)["claimtime"],
|
|
|
+ "recovertime": (*one)["recovertime"],
|
|
|
+ "expiretime": (*one)["expiretime"],
|
|
|
+ "returntime": int64(0),
|
|
|
+ "important": (*one)["spiderimportant"],
|
|
|
+ "returnreason": "转平台",
|
|
|
+ "claimrecovertype": 0,
|
|
|
+ "source": "爬虫转平台回收",
|
|
|
+ }
|
|
|
+ u.MgoEB.Save("lua_logs_claim", recovelog)
|
|
|
}
|
|
|
- u.MgoEB.Save("lua_logs_claim", recovelog)
|
|
|
} else if w == "priority" { //调整优先级
|
|
|
priority := qu.IntAll(val)
|
|
|
if priority < 0 {
|