add code for VmBeingModified endpoint
Some checks are pending
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-16 08:40:24 +10:00
parent 40fb860385
commit 19d5b2406e
7 changed files with 125 additions and 13 deletions

22
main.go
View File

@@ -78,7 +78,7 @@ func main() {
bindPort = "9443"
}
bindAddress := fmt.Sprint(bindIP, ":", bindPort)
slog.Info("Will listen on address", "ip", bindIP, "port", bindPort)
//logger.Info("Will listen on address", "ip", bindIP, "port", bindPort)
// Determine bind disable TLS
bindDisableTlsEnv := os.Getenv("BIND_DISABLE_TLS")
@@ -103,7 +103,7 @@ func main() {
// Generate certificate if required
if !(utils.FileExists(tlsCertFilename) && utils.FileExists(tlsKeyFilename)) {
slog.Warn("Specified TLS certificate or private key do not exist", "certificate", tlsCertFilename, "tls-key", tlsKeyFilename)
logger.Warn("Specified TLS certificate or private key do not exist", "certificate", tlsCertFilename, "tls-key", tlsKeyFilename)
utils.GenerateCerts(tlsCertFilename, tlsKeyFilename)
}
@@ -119,7 +119,7 @@ func main() {
}
logger.Debug("Setting VM polling cronjob frequency to", "frequency", cronFrequency)
// start background processing
// start background processing for events stored in events table
startsAt := time.Now().Add(time.Second * 10)
job, err := s.NewJob(
gocron.DurationJob(cronFrequency),
@@ -132,9 +132,23 @@ func main() {
logger.Error("failed to start cron jobs", "error", err)
os.Exit(1)
}
logger.Debug("Created event processing cron job", "job", job.ID())
slog.Debug("Created cron job", "job", job)
startsAt2 := time.Now().Add(time.Second * 10)
job2, err := s.NewJob(
gocron.DurationJob(cronFrequency),
gocron.NewTask(func() {
c.RunVcenterPoll(ctx, logger)
}), gocron.WithSingletonMode(gocron.LimitModeReschedule),
gocron.WithStartAt(gocron.WithStartDateTime(startsAt2)),
)
if err != nil {
logger.Error("failed to start cron jobs", "error", err)
os.Exit(1)
}
logger.Debug("Created vcenter polling cron job", "job", job2.ID())
// start cron scheduler
s.Start()
// Start server