mirror of
https://github.com/ayflying/p2p.git
synced 2026-03-04 17:29:22 +00:00
每天凌晨自动检测更新
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
package system
|
package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/ayflying/p2p/internal/service"
|
"github.com/ayflying/p2p/internal/service"
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gcron"
|
||||||
"github.com/gogf/gf/v2/os/gctx"
|
"github.com/gogf/gf/v2/os/gctx"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -17,6 +20,14 @@ func init() {
|
|||||||
|
|
||||||
getDev, _ := g.Cfg().GetWithEnv(gctx.New(), "dev")
|
getDev, _ := g.Cfg().GetWithEnv(gctx.New(), "dev")
|
||||||
if !getDev.Bool() {
|
if !getDev.Bool() {
|
||||||
|
// 每天0点检查更新
|
||||||
|
gcron.Add(gctx.New(), "0 0 0 * * *", func(ctx context.Context) {
|
||||||
|
err := service.System().CheckUpdate()
|
||||||
|
if err != nil {
|
||||||
|
g.Log().Errorf(ctx, "检查更新失败:%v", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
err := service.System().CheckUpdate()
|
err := service.System().CheckUpdate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.Log().Errorf(gctx.New(), "检查更新失败:%v", err)
|
g.Log().Errorf(gctx.New(), "检查更新失败:%v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user