feat: add cron
This commit is contained in:
parent
26c751ccb7
commit
f2ef06ca81
1 changed files with 16 additions and 0 deletions
|
@ -3,6 +3,7 @@ package router
|
||||||
import (
|
import (
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/go-chi/chi/v5/middleware"
|
"github.com/go-chi/chi/v5/middleware"
|
||||||
|
"github.com/go-co-op/gocron/v2"
|
||||||
|
|
||||||
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/app"
|
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/app"
|
||||||
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/controllers/taskcontroller"
|
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/controllers/taskcontroller"
|
||||||
|
@ -32,6 +33,21 @@ func (r *Router) Setup() *chi.Mux {
|
||||||
repoService := reposervice.New(r.app)
|
repoService := reposervice.New(r.app)
|
||||||
repoService.ForceUpdate()
|
repoService.ForceUpdate()
|
||||||
|
|
||||||
|
s, _ := gocron.NewScheduler()
|
||||||
|
defer func() { _ = s.Shutdown() }()
|
||||||
|
|
||||||
|
_, _ = s.NewJob(
|
||||||
|
gocron.CronJob(
|
||||||
|
"0 4 * * *",
|
||||||
|
false,
|
||||||
|
),
|
||||||
|
gocron.NewTask(
|
||||||
|
func() {
|
||||||
|
repoService.ForceUpdate()
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
taskController := taskcontroller.New(
|
taskController := taskcontroller.New(
|
||||||
r.app,
|
r.app,
|
||||||
taskService,
|
taskService,
|
||||||
|
|
Loading…
Reference in a new issue