mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-09-23 08:44:30 +02:00
.github
api
cmd
configs
init
internal
api
archiver
auth
config
graph
importer
metricDataDispatcher
metricdata
repository
routerConfig
tagger
taskManager
commitJobService.go
compressionService.go
ldapSyncService.go
retentionService.go
stopJobsExceedTime.go
taskManager.go
updateDurationService.go
updateFootprintService.go
util
pkg
tools
web
.gitignore
.goreleaser.yaml
LICENSE
Makefile
README.md
ReleaseNotes.md
go.mod
go.sum
gqlgen.yml
startDemo.sh
tools.go
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
// Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
|
// All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
package taskManager
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/ClusterCockpit/cc-backend/internal/config"
|
|
"github.com/ClusterCockpit/cc-backend/internal/repository"
|
|
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
|
"github.com/go-co-op/gocron/v2"
|
|
)
|
|
|
|
func RegisterCommitJobService() {
|
|
var frequency string
|
|
if config.Keys.CronFrequency != nil && config.Keys.CronFrequency.CommitJobWorker != "" {
|
|
frequency = config.Keys.CronFrequency.CommitJobWorker
|
|
} else {
|
|
frequency = "2m"
|
|
}
|
|
d, _ := time.ParseDuration(frequency)
|
|
log.Infof("Register commitJob service with %s interval", frequency)
|
|
|
|
s.NewJob(gocron.DurationJob(d),
|
|
gocron.NewTask(
|
|
func() {
|
|
start := time.Now()
|
|
log.Printf("Jobcache sync started at %s", start.Format(time.RFC3339))
|
|
jobRepo.SyncJobs()
|
|
repository.CallJobStartHooks()
|
|
log.Printf("Jobcache sync is done and took %s", time.Since(start))
|
|
}))
|
|
}
|