()
| 465 | } |
| 466 | |
| 467 | func (c *ServerCommand) runRecoveryMode() int { |
| 468 | config, configErrors, err := c.parseConfig() |
| 469 | if err != nil { |
| 470 | c.UI.Error(err.Error()) |
| 471 | return 1 |
| 472 | } |
| 473 | |
| 474 | // Ensure at least one config was found. |
| 475 | if config == nil { |
| 476 | c.UI.Output(wrapAtLength( |
| 477 | "No configuration files found. Please provide configurations with the " + |
| 478 | "-config flag. If you are supplying the path to a directory, please " + |
| 479 | "ensure the directory contains files with the .hcl or .json " + |
| 480 | "extension.")) |
| 481 | return 1 |
| 482 | } |
| 483 | |
| 484 | // Update the 'log' related aspects of shared config based on config/env var/cli |
| 485 | c.flags.applyLogConfigOverrides(config.SharedConfig) |
| 486 | l, err := c.configureLogging(config) |
| 487 | if err != nil { |
| 488 | c.UI.Error(err.Error()) |
| 489 | return 1 |
| 490 | } |
| 491 | c.logger = l |
| 492 | c.allLoggers = append(c.allLoggers, l) |
| 493 | |
| 494 | // reporting Errors found in the config |
| 495 | for _, cErr := range configErrors { |
| 496 | c.logger.Warn(cErr.String()) |
| 497 | } |
| 498 | |
| 499 | // Ensure logging is flushed if initialization fails |
| 500 | defer c.flushLog() |
| 501 | |
| 502 | // create GRPC logger |
| 503 | namedGRPCLogFaker := c.logger.Named("grpclogfaker") |
| 504 | grpclog.SetLogger(&grpclogFaker{ |
| 505 | logger: namedGRPCLogFaker, |
| 506 | log: os.Getenv("VAULT_GRPC_LOGGING") != "", |
| 507 | }) |
| 508 | |
| 509 | if config.Storage == nil { |
| 510 | c.UI.Output("A storage backend must be specified") |
| 511 | return 1 |
| 512 | } |
| 513 | |
| 514 | if config.DefaultMaxRequestDuration != 0 { |
| 515 | vault.DefaultMaxRequestDuration = config.DefaultMaxRequestDuration |
| 516 | } |
| 517 | |
| 518 | logProxyEnvironmentVariables(c.logger) |
| 519 | |
| 520 | // Initialize the storage backend |
| 521 | factory, exists := c.PhysicalBackends[config.Storage.Type] |
| 522 | if !exists { |
| 523 | c.UI.Error(fmt.Sprintf("Unknown storage type %s", config.Storage.Type)) |
| 524 | return 1 |
no test coverage detected