- 门店爬虫添加调试信息

This commit is contained in:
gazebo
2019-07-08 15:17:27 +08:00
parent 3ca22059f0
commit faa43fef5a

View File

@@ -29,6 +29,7 @@ func GetCityShops(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorIDs []
if err = err2; err == nil {
retVal = storeList
}
globals.SugarLogger.Debugf("GetCityShops vendorID:%d, cityCode:%d, len(storeList):%d, err:%v", vendorID, cityCode, len(storeList), err)
return retVal, err
}, vendorIDs)
tasksch.AddChild(parentTask, task).Run()
@@ -124,11 +125,13 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis
task := tasksch.NewSeqTask("GetAndStoreCitiesShops", ctx,
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
cityCode := cityCodeList[step]
globals.SugarLogger.Debugf("process city:%d", cityCode)
shopList, err := GetCityShops(ctx, task, vendorIDs, cityCode, radius, gridWith)
if err == nil {
dao.Begin(db)
defer func() {
if r := recover(); r != nil {
panic(r)
dao.Rollback(db)
}
}()
@@ -145,6 +148,7 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis
dao.Commit(db)
}
}
globals.SugarLogger.Debugf("process city:%d, len(shopList):%d, err:%v", cityCode, len(shopList), err)
return nil, nil // 强制继续
}, len(cityCodeList))
tasksch.ManageTask(task).Run()