summaryrefslogtreecommitdiff
path: root/scheduler/scheduler.go
blob: bdbab8ef7bb8aea82c88f54e206ed47dd211f4e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package scheduler

import (
	"database/sql"
	"log"
	"time"

	"git.hatecomputers.club/hatecomputers/hatecomputers.club/database"
	"github.com/go-co-op/gocron"
)

func StartScheduler(dbConn *sql.DB) {
	scheduler := gocron.NewScheduler(time.Local)
	scheduler.Every(500).Seconds().Do(func() {
		log.Println("deleting expired sessions")
		database.DeleteExpiredSessions(dbConn)
	})
	scheduler.StartAsync()
}