MCPcopy
hub / github.com/hashicorp/vault / Run

Method Run

command/server.go:1042–1907  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

1040}
1041
1042func (c *ServerCommand) Run(args []string) int {
1043 f := c.Flags()
1044
1045 if err := f.Parse(args); err != nil {
1046 c.UI.Error(err.Error())
1047 return 1
1048 }
1049
1050 // Don't exit just because we saw a potential deadlock.
1051 deadlock.Opts.OnPotentialDeadlock = func() {}
1052
1053 c.logGate = gatedwriter.NewWriter(os.Stderr)
1054 c.logWriter = c.logGate
1055
1056 if c.logFlags.flagCombineLogs {
1057 c.logWriter = os.Stdout
1058 }
1059
1060 if c.flagRecovery {
1061 return c.runRecoveryMode()
1062 }
1063
1064 // Automatically enable dev mode if other dev flags are provided.
1065 if c.flagDevConsul || c.flagDevHA || c.flagDevTransactional || c.flagDevLeasedKV || c.flagDevAutoSeal || c.flagDevKVV1 || c.flagDevNoKV || c.flagDevTLS {
1066 c.flagDev = true
1067 }
1068
1069 // Validation
1070 if !c.flagDev {
1071 switch {
1072 case len(c.flagConfigs) == 0:
1073 c.UI.Error("Must specify at least one config path using -config")
1074 return 1
1075 case c.flagDevRootTokenID != "":
1076 c.UI.Warn(wrapAtLength(
1077 "You cannot specify a custom root token ID outside of \"dev\" mode. " +
1078 "Your request has been ignored."))
1079 c.flagDevRootTokenID = ""
1080 }
1081 }
1082
1083 // Load the configuration
1084 var config *server.Config
1085 var certDir string
1086 if c.flagDev {
1087 df, cfg, dir, err := configureDevTLS(c)
1088 if df != nil {
1089 defer df()
1090 }
1091
1092 if err != nil {
1093 c.UI.Error(err.Error())
1094 return 1
1095 }
1096
1097 config = cfg
1098 certDir = dir
1099

Callers

nothing calls this directly

Calls 15

FlagsMethod · 0.95
runRecoveryModeMethod · 0.95
parseConfigMethod · 0.95
MergeMethod · 0.95
configureLoggingMethod · 0.95
flushLogMethod · 0.95
startMemProfilerMethod · 0.95
setupStorageMethod · 0.95
configureSealsMethod · 0.95
setSealsToFinalizeMethod · 0.95

Tested by

no test coverage detected