forked from topfreegames/pitaya-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal_manager_launcher.go
35 lines (29 loc) · 1.08 KB
/
local_manager_launcher.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
package launcher
import (
"time"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
pbKubernetes "github.com/topfreegames/pitaya-bot/kubernetes"
)
// LaunchLocalManager launches the manager locally, that will instantiate jobs and manage them until the end
func LaunchLocalManager(config *viper.Viper, specsDirectory string, duration time.Duration, shouldReportMetrics, deleteBeforeRun bool, logger logrus.FieldLogger) {
logger = logger.WithFields(logrus.Fields{
"function": "LaunchLocalManager",
})
specs, err := GetSpecs(specsDirectory)
if err != nil {
logger.Fatal(err)
}
logger.Infof("Found %d specs to be executed", len(specs))
clientset := newKubernetesClientset(config, logger)
if deleteBeforeRun {
pbKubernetes.DeleteAll(logger, clientset, config)
}
if pbKubernetes.CheckAll(logger, clientset, config) {
return
}
pbKubernetes.DeployJobsLocal(logger, clientset, config, specs, duration, shouldReportMetrics)
controller := pbKubernetes.NewManagerController(logger, clientset, config)
controller.Run(1, duration)
pbKubernetes.DeleteAll(logger, clientset, config)
}