mirror of https://github.com/hashicorp/consul
agent: clean up scada connection manager
parent
96e7b1869c
commit
eb8974160f
|
@ -346,17 +346,11 @@ func (c *Command) setupAgent(config *Config, logOutput io.Writer, logWriter *log
|
||||||
c.rpcServer = NewAgentRPC(agent, rpcListener, logOutput, logWriter)
|
c.rpcServer = NewAgentRPC(agent, rpcListener, logOutput, logWriter)
|
||||||
|
|
||||||
// Enable the SCADA integration
|
// Enable the SCADA integration
|
||||||
var scadaList net.Listener
|
if err := c.setupScadaConn(config); err != nil {
|
||||||
if config.AtlasInfrastructure != "" {
|
|
||||||
provider, list, err := NewProvider(config, logOutput)
|
|
||||||
if err != nil {
|
|
||||||
agent.Shutdown()
|
agent.Shutdown()
|
||||||
c.Ui.Error(fmt.Sprintf("Error starting SCADA connection: %s", err))
|
c.Ui.Error(fmt.Sprintf("Error starting SCADA connection: %s", err))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
c.scadaProvider = provider
|
|
||||||
scadaList = list
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.Ports.HTTP > 0 || config.Ports.HTTPS > 0 {
|
if config.Ports.HTTP > 0 || config.Ports.HTTPS > 0 {
|
||||||
servers, err := NewHTTPServers(agent, config, logOutput)
|
servers, err := NewHTTPServers(agent, config, logOutput)
|
||||||
|
@ -368,10 +362,6 @@ func (c *Command) setupAgent(config *Config, logOutput io.Writer, logWriter *log
|
||||||
c.httpServers = servers
|
c.httpServers = servers
|
||||||
}
|
}
|
||||||
|
|
||||||
if scadaList != nil {
|
|
||||||
c.scadaHttp = newScadaHttp(agent, scadaList)
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.Ports.DNS > 0 {
|
if config.Ports.DNS > 0 {
|
||||||
dnsAddr, err := config.ClientListener(config.Addresses.DNS, config.Ports.DNS)
|
dnsAddr, err := config.ClientListener(config.Addresses.DNS, config.Ports.DNS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -916,25 +906,39 @@ func (c *Command) handleReload(config *Config) *Config {
|
||||||
}(wp)
|
}(wp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reload the SCADA client
|
// Reload SCADA client
|
||||||
|
if err := c.setupScadaConn(newConf); err != nil {
|
||||||
|
c.Ui.Error(fmt.Sprintf("Failed reloading SCADA client: %s", err))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return newConf
|
||||||
|
}
|
||||||
|
|
||||||
|
// startScadaClient is used to start a new SCADA provider and listener,
|
||||||
|
// replacing any existing listeners.
|
||||||
|
func (c *Command) setupScadaConn(config *Config) error {
|
||||||
|
// Shut down existing SCADA listeners
|
||||||
if c.scadaProvider != nil {
|
if c.scadaProvider != nil {
|
||||||
// Shut down the existing SCADA listeners
|
|
||||||
c.scadaProvider.Shutdown()
|
c.scadaProvider.Shutdown()
|
||||||
|
}
|
||||||
if c.scadaHttp != nil {
|
if c.scadaHttp != nil {
|
||||||
c.scadaHttp.Shutdown()
|
c.scadaHttp.Shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the new provider and listener
|
// No-op if we don't have an infrastructure
|
||||||
provider, list, err := NewProvider(newConf, c.logOutput)
|
if config.AtlasInfrastructure == "" {
|
||||||
if err != nil {
|
|
||||||
c.Ui.Error(fmt.Sprintf("Failed reloading SCADA client: %s", err))
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the new provider and listener
|
||||||
|
provider, list, err := NewProvider(config, c.logOutput)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
c.scadaProvider = provider
|
c.scadaProvider = provider
|
||||||
c.scadaHttp = newScadaHttp(c.agent, list)
|
c.scadaHttp = newScadaHttp(c.agent, list)
|
||||||
}
|
return nil
|
||||||
|
|
||||||
return newConf
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Command) Synopsis() string {
|
func (c *Command) Synopsis() string {
|
||||||
|
|
Loading…
Reference in New Issue