bug(cmd): Ensure RunShutdownFuncs is called when an early error occurs (#2333)
* bug(cmd): Ensure RunShutdownFuncs is called when an early error occurs
This commit is contained in:
1 parent
4d966c8eb4
commit
dcccaf1bcf
4 files changed
+22
-12
No files matched your search
@@ -138,6 +138,12 @@ func (c *Command) AutocompleteFlags() complete.Flags {
|
||||
func (c *Command) Run(args []string) int {
|
||||
c.CombineLogs = c.flagCombineLogs
|
||||
|
||||
defer func() {
|
||||
if err := c.RunShutdownFuncs(); err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error running shutdown tasks: %w", err).Error())
|
||||
}
|
||||
}()
|
||||
|
||||
if result := c.ParseFlagsAndConfig(args); result > 0 {
|
||||
return result
|
||||
}
|
||||
@@ -471,12 +477,6 @@ func (c *Command) Run(args []string) int {
|
||||
}
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := c.RunShutdownFuncs(); err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error running shutdown tasks: %w", err).Error())
|
||||
}
|
||||
}()
|
||||
|
||||
if c.Config.Controller != nil {
|
||||
c.EnabledPlugins = append(c.EnabledPlugins, base.EnabledPluginHostAws, base.EnabledPluginHostAzure)
|
||||
if err := c.StartController(c.Context); err != nil {
|
||||
|
||||
Reference in new issue
Block a user