hatecomputers.club/scheduler/scheduler.go

20 lines
403 B
Go

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()
}