diff --git a/internal/router/router.go b/internal/router/router.go index 21cdfb6..f336ed0 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -3,6 +3,7 @@ package router import ( "github.com/go-chi/chi/v5" "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/controllers/taskcontroller" @@ -32,6 +33,21 @@ func (r *Router) Setup() *chi.Mux { repoService := reposervice.New(r.app) repoService.ForceUpdate() + s, _ := gocron.NewScheduler() + defer func() { _ = s.Shutdown() }() + + _, _ = s.NewJob( + gocron.CronJob( + "0 4 * * *", + false, + ), + gocron.NewTask( + func() { + repoService.ForceUpdate() + }, + ), + ) + taskController := taskcontroller.New( r.app, taskService,