21 lines
313 B
Go
21 lines
313 B
Go
![]() |
package cmd
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"github.com/robfig/cron/v3"
|
||
|
"hk/service/api/internal/svc"
|
||
|
)
|
||
|
|
||
|
var svcCtx *svc.ServiceContext
|
||
|
|
||
|
func Execute(ctx *svc.ServiceContext) {
|
||
|
svcCtx = ctx
|
||
|
c := cron.New(cron.WithSeconds())
|
||
|
|
||
|
ScheduleRun(c)
|
||
|
fmt.Println("定时任务启动...")
|
||
|
go c.Start()
|
||
|
defer c.Stop()
|
||
|
//select {}
|
||
|
}
|