phoneassistant/scheduler/scheduler.go

35 lines
559 B
Go
Raw Permalink Normal View History

2025-01-13 02:09:34 -05:00
package scheduler
import (
"database/sql"
"log"
"time"
"git.simponic.xyz/simponic/phoneassistant/args"
"github.com/go-co-op/gocron/v2"
)
func StartScheduler(_dbConn *sql.DB, argv *args.Arguments) {
scheduler, err := gocron.NewScheduler()
if err != nil {
panic("could not create scheduler")
}
_, err = scheduler.NewJob(
gocron.DurationJob(
24*time.Hour,
),
gocron.NewTask(
func(msg string) {
log.Println(msg)
},
"it's a beautiful new day!",
),
)
if err != nil {
panic("could not create job")
}
scheduler.Start()
}