refact(controller): Decouple listeners/servers shutdown from Worker
In general, these changes were introduced in the same vein of the changes to controller `startListeners`. Specifically, these changes also decouple the Controller and the Worker shutdown processes. Currently, a call to `stopListeners` on an instance that is running as both a Controller and a Worker would stop the listeners for both. Lastly, we also add unit/integration tests to the shutdown code.
This commit is contained in:
1 parent
d438a6d2dd
commit
eebdfb88dc
9 files changed
+572
-72
No files matched your search
@@ -618,7 +618,7 @@ func (c *Command) Run(args []string) int {
|
||||
|
||||
if err := c.controller.Start(); err != nil {
|
||||
retErr := fmt.Errorf("Error starting controller: %w", err)
|
||||
if err := c.controller.Shutdown(false); err != nil {
|
||||
if err := c.controller.Shutdown(); err != nil {
|
||||
c.UI.Error(retErr.Error())
|
||||
retErr = fmt.Errorf("Error shutting down controller: %w", err)
|
||||
}
|
||||
@@ -647,7 +647,7 @@ func (c *Command) Run(args []string) int {
|
||||
retErr = fmt.Errorf("Error shutting down worker: %w", err)
|
||||
}
|
||||
c.UI.Error(retErr.Error())
|
||||
if err := c.controller.Shutdown(false); err != nil {
|
||||
if err := c.controller.Shutdown(); err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error with controller shutdown: %w", err).Error())
|
||||
}
|
||||
return base.CommandCliError
|
||||
@@ -684,7 +684,7 @@ func (c *Command) Run(args []string) int {
|
||||
}
|
||||
}
|
||||
|
||||
if err := c.controller.Shutdown(false); err != nil {
|
||||
if err := c.controller.Shutdown(); err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error shutting down controller: %w", err).Error())
|
||||
}
|
||||
|
||||
|
||||
@@ -465,7 +465,7 @@ func (c *Command) Run(args []string) int {
|
||||
if err := c.StartWorker(); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
if c.controller != nil {
|
||||
if err := c.controller.Shutdown(false); err != nil {
|
||||
if err := c.controller.Shutdown(); err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error with controller shutdown: %w", err).Error())
|
||||
}
|
||||
}
|
||||
@@ -601,7 +601,7 @@ func (c *Command) StartController(ctx context.Context) error {
|
||||
|
||||
if err := c.controller.Start(); err != nil {
|
||||
retErr := fmt.Errorf("Error starting controller: %w", err)
|
||||
if err := c.controller.Shutdown(false); err != nil {
|
||||
if err := c.controller.Shutdown(); err != nil {
|
||||
c.UI.Error(retErr.Error())
|
||||
retErr = fmt.Errorf("Error shutting down controller: %w", err)
|
||||
}
|
||||
@@ -669,7 +669,7 @@ func (c *Command) WaitForInterrupt() int {
|
||||
|
||||
// Do controller shutdown
|
||||
if c.Config.Controller != nil {
|
||||
if err := c.controller.Shutdown(c.Config.Worker != nil); err != nil {
|
||||
if err := c.controller.Shutdown(); err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error shutting down controller: %w", err).Error())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user