Skip to content

Commit

Permalink
fix: repo type defaults to "repo"
Browse files Browse the repository at this point in the history
resolves #18
  • Loading branch information
LeslieLeung committed Dec 17, 2023
1 parent 0f5ffc1 commit 65c6080
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 67 deletions.
18 changes: 13 additions & 5 deletions cmd/daemon/daemon.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package daemon

import (
"github.com/go-co-op/gocron"
"github.com/go-co-op/gocron/v2"
"github.com/leslieleung/reaper/internal/config"
"github.com/leslieleung/reaper/internal/rip"
"github.com/leslieleung/reaper/internal/typedef"
Expand All @@ -19,8 +19,13 @@ var Cmd = &cobra.Command{
func runDaemon(cmd *cobra.Command, args []string) {
storageMap := config.GetStorageMap()

s := gocron.NewScheduler(time.Local)
s.SetMaxConcurrentJobs(3, gocron.WaitMode)
s, err := gocron.NewScheduler(
gocron.WithLocation(time.Local),
gocron.WithLimitConcurrentJobs(3, gocron.LimitModeWait),
)
if err != nil {
ui.ErrorfExit("Error creating scheduler, %s", err)
}

for _, repo := range rip.GetRepositories("") {
if repo.Cron == "" {
Expand All @@ -34,12 +39,15 @@ func runDaemon(cmd *cobra.Command, args []string) {
storages = append(storages, s)
}
}
_, err := s.Cron(repo.Cron).Do(rip.Rip, repo, storages)
_, err := s.NewJob(
gocron.CronJob(repo.Cron, false),
gocron.NewTask(rip.Rip, repo, storages),
)
if err != nil {
ui.Errorf("Error scheduling %s, %s", repo.Name, err)
}
ui.Printf("Scheduled %s, cron: %s", repo.Name, repo.Cron)
}
ui.Printf("Starting daemon")
s.StartBlocking()
s.Start()
}
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ module github.com/leslieleung/reaper
go 1.21

require (
github.com/go-co-op/gocron/v2 v2.0.2
github.com/go-co-op/gocron/v2 v2.0.2
github.com/go-git/go-git/v5 v5.11.0
github.com/google/go-github/v56 v56.0.0
github.com/google/go-github/v57 v57.0.0
github.com/google/uuid v1.5.0
github.com/gookit/color v1.5.4
github.com/mholt/archiver/v4 v4.0.0-alpha.8
Expand All @@ -20,7 +18,6 @@ require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/bodgit/plumbing v1.2.0 // indirect
github.com/bodgit/sevenzip v1.3.0 // indirect
Expand All @@ -42,6 +39,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jonboulle/clockwork v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect
Expand Down
Loading

0 comments on commit 65c6080

Please sign in to comment.