|
|
|
@ -215,35 +215,38 @@ func StartGateway(ctx *cli.Context, gw Gateway) { |
|
|
|
|
|
|
|
|
|
signal.Notify(globalOSSignalCh, os.Interrupt, syscall.SIGTERM) |
|
|
|
|
|
|
|
|
|
newObject, err := gw.NewGatewayLayer(globalServerConfig.GetCredential()) |
|
|
|
|
if err != nil { |
|
|
|
|
// Stop watching for any certificate changes.
|
|
|
|
|
globalTLSCerts.Stop() |
|
|
|
|
|
|
|
|
|
globalHTTPServer.Shutdown() |
|
|
|
|
logger.FatalIf(err, "Unable to initialize gateway backend") |
|
|
|
|
} |
|
|
|
|
// Create a new config system.
|
|
|
|
|
globalConfigSys = NewConfigSys() |
|
|
|
|
if globalEtcdClient != nil && gatewayName == "nas" { |
|
|
|
|
// Initialize server config.
|
|
|
|
|
_ = globalConfigSys.Init(newObject) |
|
|
|
|
} else { |
|
|
|
|
// !!! Do not move this block !!!
|
|
|
|
|
// For all gateways, the config needs to be loaded from env
|
|
|
|
|
// prior to initializing the gateway layer
|
|
|
|
|
{ |
|
|
|
|
// Initialize server config.
|
|
|
|
|
srvCfg := newServerConfig() |
|
|
|
|
|
|
|
|
|
// Override any values from ENVs.
|
|
|
|
|
srvCfg.loadFromEnvs() |
|
|
|
|
|
|
|
|
|
// Load values to cached global values.
|
|
|
|
|
srvCfg.loadToCachedConfigs() |
|
|
|
|
|
|
|
|
|
// hold the mutex lock before a new config is assigned.
|
|
|
|
|
globalServerConfigMu.Lock() |
|
|
|
|
globalServerConfig = srvCfg |
|
|
|
|
globalServerConfigMu.Unlock() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
newObject, err := gw.NewGatewayLayer(globalServerConfig.GetCredential()) |
|
|
|
|
if err != nil { |
|
|
|
|
// Stop watching for any certificate changes.
|
|
|
|
|
globalTLSCerts.Stop() |
|
|
|
|
|
|
|
|
|
globalHTTPServer.Shutdown() |
|
|
|
|
logger.FatalIf(err, "Unable to initialize gateway backend") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if globalEtcdClient != nil && gatewayName == "nas" { |
|
|
|
|
// Create a new config system.
|
|
|
|
|
globalConfigSys = NewConfigSys() |
|
|
|
|
|
|
|
|
|
// Load globalServerConfig from etcd
|
|
|
|
|
_ = globalConfigSys.Init(newObject) |
|
|
|
|
} |
|
|
|
|
// Load logger subsystem
|
|
|
|
|
loadLoggers() |
|
|
|
|
|
|
|
|
|