1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 00:09:16 +08:00

feat: 增加应用商店定时同步 (#1231)

This commit is contained in:
zhengkunwang223 2023-06-02 14:23:24 +08:00 committed by GitHub
parent 6919ce7b5c
commit 3ad3b180af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -39,6 +39,9 @@ func Run() {
if _, err := global.Cron.AddJob("@daily", job.NewSSLJob()); err != nil {
global.LOG.Errorf("can not add ssl corn job: %s", err.Error())
}
if _, err := global.Cron.AddJob("@daily", job.NewAppStoreJob()); err != nil {
global.LOG.Errorf("can not add appstore corn job: %s", err.Error())
}
global.Cron.Start()
var cronJobs []model.Cronjob

20
backend/cron/job/app.go Normal file
View File

@ -0,0 +1,20 @@
package job
import (
"github.com/1Panel-dev/1Panel/backend/app/service"
"github.com/1Panel-dev/1Panel/backend/global"
)
type app struct{}
func NewAppStoreJob() *app {
return &app{}
}
func (a *app) Run() {
global.LOG.Info("AppStore scheduled task in progress ...")
if err := service.NewIAppService().SyncAppListFromRemote(); err != nil {
global.LOG.Errorf("AppStore sync failed %s", err.Error())
}
global.LOG.Info("AppStore scheduled task has completed")
}