-
Notifications
You must be signed in to change notification settings - Fork 128
/
main.go
61 lines (49 loc) · 1.65 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"net/http"
"os"
"os/signal"
"syscall"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"github.com/armadaproject/armada/internal/common"
"github.com/armadaproject/armada/internal/common/health"
"github.com/armadaproject/armada/internal/executor"
"github.com/armadaproject/armada/internal/executor/configuration"
"github.com/armadaproject/armada/internal/executor/metrics"
)
const CustomConfigLocation string = "config"
func init() {
pflag.StringSlice(
CustomConfigLocation,
[]string{},
"Fully qualified path to application configuration file (for multiple config files repeat this arg or separate paths with commas)",
)
pflag.Parse()
}
func main() {
common.ConfigureLogging()
common.BindCommandlineArguments()
var config configuration.ExecutorConfiguration
userSpecifiedConfigs := viper.GetStringSlice(CustomConfigLocation)
common.LoadConfig(&config, "./config/executor", userSpecifiedConfigs)
mux := http.NewServeMux()
startupCompleteCheck := health.NewStartupCompleteChecker()
healthChecks := health.NewMultiChecker(startupCompleteCheck)
health.SetupHttpMux(mux, healthChecks)
shutdownHttpServer := common.ServeHttp(config.HttpPort, mux)
defer shutdownHttpServer()
shutdownChannel := make(chan os.Signal, 1)
signal.Notify(shutdownChannel, syscall.SIGINT, syscall.SIGTERM)
shutdownMetricServer := common.ServeMetricsFor(config.Metric.Port,
prometheus.Gatherers{metrics.GetMetricsGatherer()})
defer shutdownMetricServer()
shutdown, wg := executor.StartUp(config)
go func() {
<-shutdownChannel
shutdown()
}()
startupCompleteCheck.MarkComplete()
wg.Wait()
}