Main is a helper function to start a standard ContainerSSH instance. It should be used as the outer-most function and should never be used as an embedding technique.
()
| 24 | // Main is a helper function to start a standard ContainerSSH instance. It should be used as the outer-most function |
| 25 | // and should never be used as an embedding technique. |
| 26 | func Main() { |
| 27 | cfg := config.AppConfig{} |
| 28 | cfg.Default() |
| 29 | |
| 30 | loggerFactory := log.NewLoggerFactory() |
| 31 | logger, err := loggerFactory.Make( |
| 32 | cfg.Log, |
| 33 | ) |
| 34 | if err != nil { |
| 35 | panic(err) |
| 36 | } |
| 37 | |
| 38 | logger = logger.WithLabel("module", "core") |
| 39 | |
| 40 | configFile, actionDumpConfig, actionLicenses, actionHealthCheck := getArguments() |
| 41 | |
| 42 | if configFile == "" { |
| 43 | configFile = "config.yaml" |
| 44 | } |
| 45 | realConfigFile, err := filepath.Abs(configFile) |
| 46 | if err != nil { |
| 47 | logger.Critical( |
| 48 | message.Wrap( |
| 49 | err, |
| 50 | message.ECoreConfig, |
| 51 | "Failed to fetch absolute path for configuration file %s", |
| 52 | configFile, |
| 53 | )) |
| 54 | os.Exit(1) |
| 55 | } |
| 56 | configFile = realConfigFile |
| 57 | if err = readConfigFile(configFile, loggerFactory, &cfg); err != nil { |
| 58 | logger.Critical( |
| 59 | message.Wrap( |
| 60 | err, |
| 61 | message.ECoreConfig, |
| 62 | "Invalid configuration in file %s", |
| 63 | configFile, |
| 64 | )) |
| 65 | os.Exit(1) |
| 66 | } |
| 67 | |
| 68 | configuredLogger, err := loggerFactory.Make( |
| 69 | cfg.Log, |
| 70 | ) |
| 71 | if err != nil { |
| 72 | logger.Critical(err) |
| 73 | os.Exit(1) |
| 74 | } |
| 75 | configuredLogger.Debug(message.NewMessage(message.MCoreConfigFile, "Using configuration file %s...", configFile)) |
| 76 | |
| 77 | switch { |
| 78 | case actionDumpConfig: |
| 79 | runDumpConfig(cfg, configuredLogger) |
| 80 | case actionLicenses: |
| 81 | runActionLicenses(configuredLogger) |
| 82 | case actionHealthCheck: |
| 83 | runHealthCheck(cfg, configuredLogger) |
no test coverage detected