in src/go/gcsrunner/main/runner.go [61:126]
func main() {
flag.Set("alsologtostderr", "true")
flag.Parse()
bucketName := os.Getenv("BUCKET")
if bucketName == "" {
glog.Fatal("Must specify the BUCKET environment variable.")
}
configFileName := os.Getenv("CONFIG_FILE_NAME")
if configFileName == "" {
glog.Fatal("Must specify the CONFIG_FILE_NAME environment variable.")
}
logLevel := os.Getenv("ENVOY_LOG_LEVEL")
if logLevel == "" {
logLevel = *envoyLogLevel
}
componentLogLevel := os.Getenv("ENVOY_COMPONENT_LOG_LEVEL")
if componentLogLevel == "" {
componentLogLevel = *envoyComponentLogLevel
}
logPath := os.Getenv("ENVOY_LOG_PATH")
if logPath == "" {
logPath = *envoyLogPath
}
envoyBin := os.Getenv("ENVOY_BIN_PATH")
if envoyBin == "" {
envoyBin = *envoyBinaryPath
}
runAsSA := os.Getenv("RUN_AS_SERVICE_ACCOUNT")
if runAsSA == "" {
runAsSA = *sa
}
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM)
start := time.Now()
if err := gcsrunner.FetchConfigFromGCS(gcsrunner.FetchConfigOptions{
BucketName: bucketName,
ConfigFileName: configFileName,
FetchGCSObjectInitialInterval: fetchGCSObjectInitialInterval,
FetchGCSObjectTimeout: fetchGCSObjectTimeout,
WriteFilePath: envoyConfigPath,
ServiceAccount: runAsSA,
}); err != nil {
glog.Fatalf("Failed to fetch config: %v", err)
}
glog.Infof("fetched config from GCS in %s", time.Since(start))
if err := gcsrunner.StartEnvoyAndWait(signalChan, gcsrunner.StartEnvoyOptions{
BinaryPath: envoyBin,
ComponentLogLevel: componentLogLevel,
ConfigPath: envoyConfigPath,
LogLevel: logLevel,
LogPath: logPath,
TerminateTimeout: terminateEnvoyTimeout,
}); err != nil {
glog.Fatalf("Envoy erred: %v", err)
}
}