Initial commit

This commit is contained in:
微凉
2020-12-24 01:39:45 +08:00
commit 430b4cf723
30 changed files with 1223 additions and 0 deletions

26
bootstrap/cron.go Normal file
View File

@@ -0,0 +1,26 @@
package bootstrap
import (
"github.com/Xhofe/alist/alidrive"
"github.com/Xhofe/alist/conf"
"github.com/Xhofe/alist/utils"
"github.com/robfig/cron/v3"
log "github.com/sirupsen/logrus"
)
var Cron *cron.Cron
func refreshToken() {
alidrive.RefreshToken()
utils.WriteToYml(conf.Con,conf.Conf)
}
func InitCron() {
log.Infof("初始化定时任务:刷新token")
Cron=cron.New()
_,err:=Cron.AddFunc("@every 2h",refreshToken)
if err!=nil {
log.Errorf("添加启动任务失败:%s",err.Error())
}
Cron.Start()
}