- replace all goroutine and AfterFunc with recover version

This commit is contained in:
gazebo
2019-03-15 10:26:30 +08:00
parent e5bf25bd04
commit dec14126a7
14 changed files with 30 additions and 29 deletions

View File

@@ -14,7 +14,7 @@ func Init() {
func RefreshEbaiRealMobile() {
ebai.CurPurchaseHandler.RefreshRealMobile(jxcontext.AdminCtx, time.Now().Add(-6*time.Hour), utils.DefaultTimeValue, true, true)
time.AfterFunc(1*time.Hour, func() {
utils.AfterFuncWithRecover(1*time.Hour, func() {
RefreshEbaiRealMobile()
})
}

View File

@@ -205,7 +205,7 @@ func scheduleDailyRoutine(isFirst bool) {
UpdateJdPromotionStatus()
}
// globals.SugarLogger.Debug(duration)
time.AfterFunc(duration, func() {
utils.AfterFuncWithRecover(duration, func() {
UpdateJdPromotionStatus()
scheduleDailyRoutine(false)
})
@@ -213,12 +213,12 @@ func scheduleDailyRoutine(isFirst bool) {
func scheduleRoutine(isFirst bool) {
if isFirst {
go func() {
utils.CallFuncAsync(func() {
RefreshJdLockStoreSku()
RefreshJdStoreSkuStock(0, nil)
}()
})
}
time.AfterFunc(stockRefreshGap, func() {
utils.AfterFuncWithRecover(stockRefreshGap, func() {
RefreshJdLockStoreSku()
RefreshJdStoreSkuStock(0, nil)
scheduleRoutine(false)
@@ -887,7 +887,7 @@ func OnStoreStockMsg(msg *jdapi.CallbackStoreStockMsg) (retVal *jdapi.CallbackRe
sku := &model.Sku{}
sku.JdID = msg.SkuId
if err = dao.GetEntity(db, sku, model.FieldJdID); err == nil {
go func() {
utils.CallFuncAsync(func() {
if msg.Vendibility == 1 {
vendibility := &jdapi.StockVendibility{
OutSkuId: utils.Int2Str(sku.ID),
@@ -906,7 +906,7 @@ func OnStoreStockMsg(msg *jdapi.CallbackStoreStockMsg) (retVal *jdapi.CallbackRe
stock,
}, userName)
}
}()
})
}
}
return jdapi.Err2CallbackResponse(err, "")
@@ -917,7 +917,7 @@ func OnNewPromotionMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackRespo
}
func createLocalPromotionFromRemote(promotionInfoId int64) (retVal *jdapi.CallbackResponse) {
go func() {
utils.CallFuncAsync(func() {
result, err := api.JdAPI.QueryPromotionInfo(promotionInfoId)
if err == nil {
db := dao.GetDB()
@@ -1005,7 +1005,7 @@ func createLocalPromotionFromRemote(promotionInfoId int64) (retVal *jdapi.Callba
}
}
}
}()
})
return jdapi.Err2CallbackResponse(nil, "")
}