-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (35 loc) · 846 Bytes
/
main.go
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
35
36
37
38
39
40
41
// Package main provides the main entry point for the jobd application
package main
import (
"flag"
router "jobd/controllers"
"jobd/datasource/db"
"jobd/services"
"log"
"time"
"github.com/go-co-op/gocron"
)
func init() {
_ = flag.Set("logtostderr", "true")
_ = flag.Set("stderrthreshold", "DEBUG")
_ = flag.Set("v", "2")
flag.Parse()
}
// @title jobd (Job Daemon) API
// @version 1.0
// @description API for managing job queue in jobd application
// @BasePath /api
func main() {
errDB := db.InitDB()
if errDB != nil {
log.Fatal(errDB)
}
s := gocron.NewScheduler(time.UTC)
s.SetMaxConcurrentJobs(1, gocron.RescheduleMode)
s.Every(1).Seconds().Do(services.RunTasks)
s.Every(30).Seconds().Do(services.UpdateSlurmlJobs)
s.Every(1).Hours().Do(services.ClearOldJobs)
s.StartAsync()
r := router.SetupRouter()
_ = r.Run()
}