assing 12am-8am only
parent
a74f741298
commit
be148f5de5
|
|
@ -3,10 +3,12 @@ package asses
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"log"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"show-rss/src/asses"
|
"show-rss/src/asses"
|
||||||
"show-rss/src/cron"
|
"show-rss/src/cron"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var rootDs = []string{
|
var rootDs = []string{
|
||||||
|
|
@ -17,6 +19,16 @@ var rootDs = []string{
|
||||||
type CB func(context.Context, string) error
|
type CB func(context.Context, string) error
|
||||||
|
|
||||||
func Main(ctx context.Context) error {
|
func Main(ctx context.Context) error {
|
||||||
|
midnightLastNight, err := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
deadline := midnightLastNight.Add(8 * time.Hour) // midnight-8AM
|
||||||
|
log.Printf("assing until %v (%v)", deadline, time.Until(deadline))
|
||||||
|
|
||||||
|
ctx, can := context.WithDeadline(ctx, deadline)
|
||||||
|
defer can()
|
||||||
|
|
||||||
return cron.Cron(ctx, asses.Next, One)
|
return cron.Cron(ctx, asses.Next, One)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue