summaryrefslogtreecommitdiff
path: root/template/scheduler/scheduler.go
blob: cff3a3ab745583b41e6c3382b6f190f094cff045 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()
}