maxiaoshan %!s(int64=3) %!d(string=hai) anos
pai
achega
f4c2a4d8f8
Modificáronse 2 ficheiros con 10 adicións e 6 borrados
  1. 6 6
      src/spider/handler.go
  2. 4 0
      src/spider/spider.go

+ 6 - 6
src/spider/handler.go

@@ -107,7 +107,7 @@ func NoQueueScript() {
 				sp.MUserEmail = info["modifyemail"]
 				Allspiders.Store(sp.Code, sp)
 				//创建多个spider对象
-				NewMoreSpider(code, script, sp)
+				NewMoreSpider(code, script, sp.MUserName, sp.MUserEmail, sp.UserName, sp.UserEmail)
 				// for _, tmp := range *list {
 				// 	if qu.ObjToString(tmp["code"]) == sp.Code {
 				// 		sp.UpperLimit = qu.IntAll(tmp["uplimit"])
@@ -201,14 +201,14 @@ func NewSpider(code, luafile string) *Spider {
 }
 
 //为某个爬虫创建多个spider对象
-func NewMoreSpider(code, script string, sp *Spider) {
+func NewMoreSpider(code, script, mname, memail, uname, uemail string) {
 	defer qu.Catch()
 	for i := 1; i <= CodeChan[code]; i++ {
 		spTmp := NewSpider(code, script)
-		spTmp.UserEmail = sp.UserEmail
-		spTmp.UserName = sp.UserName
-		spTmp.MUserEmail = sp.MUserEmail
-		spTmp.MUserName = sp.MUserName
+		spTmp.UserEmail = uemail
+		spTmp.UserName = uname
+		spTmp.MUserEmail = memail
+		spTmp.MUserName = mname
 		AllspidersMapLock.Lock()
 		AllspidersMap[code] = append(AllspidersMap[code], spTmp)
 		AllspidersMapLock.Unlock()

+ 4 - 0
src/spider/spider.go

@@ -12,6 +12,7 @@ import (
 	"math/big"
 	"math/rand"
 	mu "mfw/util"
+	"os"
 	qu "qfw/util"
 	"regexp"
 	util "spiderutil"
@@ -165,6 +166,9 @@ func DownloadHighDetail(code string) {
 							if len(tmp) > 0 {
 								SaveErrorData(sp.MUserName, tmp, err) //保存错误信息
 							}
+							if errstr := err.(string); errstr == "d.nx != 0" { //downloadFile出错,杀程序
+								os.Exit(-1)
+							}
 						} /*else if data == nil && times >= 3 { //下载问题,建editor任务
 							DownloadErrorData(s.Code, tmp)
 						}*/