fix schedule
This commit is contained in:
parent
4bbf4243c7
commit
6154e95d32
1 changed files with 12 additions and 9 deletions
|
|
@ -36,21 +36,20 @@ func main() {
|
||||||
|
|
||||||
sched := sked.New(ctx)
|
sched := sked.New(ctx)
|
||||||
googleLinkStream := make(chan domain.GoogleLink, 100)
|
googleLinkStream := make(chan domain.GoogleLink, 100)
|
||||||
// pages := []int{0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}
|
pages := []int{0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}
|
||||||
pages := []int{90}
|
|
||||||
|
|
||||||
log.Println("Starting scraper with scheduler...")
|
log.Println("Starting scraper with scheduler...")
|
||||||
|
|
||||||
for _, page := range pages {
|
for _, page := range pages {
|
||||||
// Work(ctx)(page, googleLinkStream)
|
go func() {
|
||||||
sched.Schedule(func(ctx context.Context) {
|
log.Printf("Running initial scrape for page offset: %d", page)
|
||||||
log.Printf("Running scrape for page offset: %d", page)
|
|
||||||
Work(ctx)(page, googleLinkStream)
|
Work(ctx)(page, googleLinkStream)
|
||||||
}).Every(24 * time.Hour)
|
}()
|
||||||
}
|
|
||||||
|
|
||||||
if err := sched.Run(); err != nil {
|
sched.Schedule(func(ctx context.Context) {
|
||||||
log.Fatalf("Failed to start scheduler: %v", err)
|
log.Printf("Running scheduled scrape for page offset: %d", page)
|
||||||
|
Work(ctx)(page, googleLinkStream)
|
||||||
|
}).Every(time.Minute * 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|
@ -103,6 +102,10 @@ func main() {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
if err := sched.Run(); err != nil {
|
||||||
|
log.Fatalf("Failed to start scheduler: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||||
<-c
|
<-c
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue