func (a *Agent) Shutdown() error {
	a.shutdownLock.Lock()
	defer a.shutdownLock.Unlock()

	if a.shutdown {
		return nil
	}

	a.logger.Println("[INFO] agent: requesting shutdown")
	if a.client != nil {
		if err := a.client.Shutdown(); err != nil {
			a.logger.Printf("[ERR] agent: client shutdown failed: %v", err)
		}
	}
	if a.server != nil {
		if err := a.server.Shutdown(); err != nil {
			a.logger.Printf("[ERR] agent: server shutdown failed: %v", err)
		}
	}

	if err := a.consulService.Shutdown(); err != nil {
		a.logger.Printf("[ERR] agent: shutting down Consul client failed: %v", err)
	}

	a.logger.Println("[INFO] agent: shutdown complete")
	a.shutdown = true
	close(a.shutdownCh)
	return nil
}
// Shutdown is used to terminate the agent.
Shutdown is used to terminate the agent.
// Shutdown is used to terminate the agent .
func (a *Agent) Shutdown() error {
	a.shutdownLock.Lock()
	defer a.shutdownLock.Unlock()
	if a.shutdown {
		return nil
	}
	a.logger.Println("[INFO] agent: requesting shutdown")
	if a.client != nil {
		if err := a.client.Shutdown(); err != nil {
			a.logger.Printf("[ERR] agent: client shutdown failed: %v", err)
		}
	}
	if a.server != nil {
		if err := a.server.Shutdown(); err != nil {
			a.logger.Printf("[ERR] agent: server shutdown failed: %v", err)
		}
	}
	if err := a.consulService.Shutdown(); err != nil {
		a.logger.Printf("[ERR] agent: shutting down Consul client failed: %v", err)
	}
	a.logger.Println("[INFO] agent: shutdown complete")
	a.shutdown = true
	close(a.shutdownCh)
	return nil
}
func ( a * Agent ) Shutdown ( ) error { a . shutdownLock . Lock ( ) defer a . shutdownLock . Unlock ( ) if a . shutdown { return nil } a . logger . Println ( " " ) if a . client != nil { if err := a . client . Shutdown ( ) ; err != nil { a . logger . Printf ( " " , err ) } } if a . server != nil { if err := a . server . Shutdown ( ) ; err != nil { a . logger . Printf ( " " , err ) } } if err := a . consulService . Shutdown ( ) ; err != nil { a . logger . Printf ( " " , err ) } a . logger . Println ( " " ) a . shutdown = true close ( a . shutdownCh ) return nil }
Shutdown is used to terminate the agent.
Shutdown is used to terminate the agent .