From 3ad3b180af264e4d3b9dcad05f9f8d3cda7e349d Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com> Date: Fri, 2 Jun 2023 14:23:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=95=86=E5=BA=97=E5=AE=9A=E6=97=B6=E5=90=8C=E6=AD=A5=20(#1231?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/cron/cron.go | 3 +++ backend/cron/job/app.go | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 backend/cron/job/app.go diff --git a/backend/cron/cron.go b/backend/cron/cron.go index 6fdf00c7d..448955f53 100644 --- a/backend/cron/cron.go +++ b/backend/cron/cron.go @@ -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 diff --git a/backend/cron/job/app.go b/backend/cron/job/app.go new file mode 100644 index 000000000..92142f021 --- /dev/null +++ b/backend/cron/job/app.go @@ -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") +}