Skip to content

Commit 65c6080

Browse files
committed
fix: repo type defaults to "repo"
resolves #18
1 parent 0f5ffc1 commit 65c6080

4 files changed

Lines changed: 27 additions & 67 deletions

File tree

cmd/daemon/daemon.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package daemon
22

33
import (
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{
1919
func 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
}

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ module github.com/leslieleung/reaper
33
go 1.21
44

55
require (
6-
github.com/go-co-op/gocron/v2 v2.0.2
76
github.com/go-co-op/gocron/v2 v2.0.2
87
github.com/go-git/go-git/v5 v5.11.0
98
github.com/google/go-github/v56 v56.0.0
10-
github.com/google/go-github/v57 v57.0.0
119
github.com/google/uuid v1.5.0
1210
github.com/gookit/color v1.5.4
1311
github.com/mholt/archiver/v4 v4.0.0-alpha.8
@@ -20,7 +18,6 @@ require (
2018
dario.cat/mergo v1.0.0 // indirect
2119
github.com/Microsoft/go-winio v0.6.1 // indirect
2220
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
23-
github.com/acomagu/bufpipe v1.0.4 // indirect
2421
github.com/andybalholm/brotli v1.0.4 // indirect
2522
github.com/bodgit/plumbing v1.2.0 // indirect
2623
github.com/bodgit/sevenzip v1.3.0 // indirect
@@ -42,6 +39,7 @@ require (
4239
github.com/hashicorp/hcl v1.0.0 // indirect
4340
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4441
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
42+
github.com/jonboulle/clockwork v0.4.0 // indirect
4543
github.com/json-iterator/go v1.1.12 // indirect
4644
github.com/kevinburke/ssh_config v1.2.0 // indirect
4745
github.com/klauspost/compress v1.17.4 // indirect

0 commit comments

Comments
 (0)