feat cron 显示下次运行时间
This commit is contained in:
parent
0cdbd49118
commit
5ce4d0000b
@ -3,6 +3,8 @@ package cron
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Cron struct {
|
type Cron struct {
|
||||||
@ -45,6 +47,7 @@ func (c *Cron) Run(ctx context.Context) {
|
|||||||
if time.Now().After(c.time) {
|
if time.Now().After(c.time) {
|
||||||
c.time = c.time.Add(time.Hour * 24)
|
c.time = c.time.Add(time.Hour * 24)
|
||||||
}
|
}
|
||||||
|
glog.Infof("cron 下次运行时间: %s", c.time)
|
||||||
select {
|
select {
|
||||||
case <-time.After(time.Until(c.time)):
|
case <-time.After(time.Until(c.time)):
|
||||||
if c.f != nil {
|
if c.f != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user