11package daemon
22
33import (
4- "github.com/go-co-op/gocron"
4+ "github.com/go-co-op/gocron/v2 "
55 "github.com/leslieleung/reaper/internal/config"
66 "github.com/leslieleung/reaper/internal/rip"
77 "github.com/leslieleung/reaper/internal/typedef"
@@ -19,8 +19,13 @@ var Cmd = &cobra.Command{
1919func runDaemon (cmd * cobra.Command , args []string ) {
2020 storageMap := config .GetStorageMap ()
2121
22- s := gocron .NewScheduler (time .Local )
23- s .SetMaxConcurrentJobs (3 , gocron .WaitMode )
22+ s , err := gocron .NewScheduler (
23+ gocron .WithLocation (time .Local ),
24+ gocron .WithLimitConcurrentJobs (3 , gocron .LimitModeWait ),
25+ )
26+ if err != nil {
27+ ui .ErrorfExit ("Error creating scheduler, %s" , err )
28+ }
2429
2530 for _ , repo := range rip .GetRepositories ("" ) {
2631 if repo .Cron == "" {
@@ -34,12 +39,15 @@ func runDaemon(cmd *cobra.Command, args []string) {
3439 storages = append (storages , s )
3540 }
3641 }
37- _ , err := s .Cron (repo .Cron ).Do (rip .Rip , repo , storages )
42+ _ , err := s .NewJob (
43+ gocron .CronJob (repo .Cron , false ),
44+ gocron .NewTask (rip .Rip , repo , storages ),
45+ )
3846 if err != nil {
3947 ui .Errorf ("Error scheduling %s, %s" , repo .Name , err )
4048 }
4149 ui .Printf ("Scheduled %s, cron: %s" , repo .Name , repo .Cron )
4250 }
4351 ui .Printf ("Starting daemon" )
44- s .StartBlocking ()
52+ s .Start ()
4553}
0 commit comments