-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.go
43 lines (41 loc) · 876 Bytes
/
run.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package ServiceAD
import (
CoreLog "github.com/fotomxq/weeekj_core/v5/core/log"
CoreSystemClose "github.com/fotomxq/weeekj_core/v5/core/system_close"
"github.com/robfig/cron"
)
func Run() {
//捕捉异常
defer func() {
if r := recover(); r != nil {
CoreLog.Error("service ad run, ", r)
}
}()
//启动定时器
runTimer = cron.New()
if err := runTimer.AddFunc("0 50 2 * * *", func() {
if runHistoryLock {
return
}
runHistoryLock = true
runHistory()
runHistoryLock = false
}); err != nil {
CoreLog.Error("service ad run, cron time, ", err)
}
if err := runTimer.AddFunc("@every 5m", func() {
if runEndLock {
return
}
runEndLock = true
runEnd()
runEndLock = false
}); err != nil {
CoreLog.Error("service ad run, cron time, ", err)
}
runTimer.Start()
//卡住进程
CoreSystemClose.Wait()
//退出时间
runTimer.Stop()
}