assing 12am-8am only

main
bel 2025-05-17 21:10:44 -06:00
parent a74f741298
commit be148f5de5
1 changed files with 12 additions and 0 deletions

View File

@ -3,10 +3,12 @@ package asses
import (
"context"
"io/fs"
"log"
"path"
"path/filepath"
"show-rss/src/asses"
"show-rss/src/cron"
"time"
)
var rootDs = []string{
@ -17,6 +19,16 @@ var rootDs = []string{
type CB func(context.Context, string) 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)
}