35 lines
550 B
Go
35 lines
550 B
Go
package scheduler
|
|
|
|
import (
|
|
"database/sql"
|
|
"log"
|
|
"time"
|
|
|
|
"git.simponic.xyz/simponic/whois/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()
|
|
}
|