backport of commit 8ff31f32a525ed32273a65e6d28b88e24e9cf06e (#20895)
Co-authored-by: Anton Averchenkov <84287187+averche@users.noreply.github.com>
This commit is contained in:
parent
afef4629c8
commit
76929df206
|
@ -838,16 +838,21 @@ func (c *AgentCommand) Run(args []string) int {
|
|||
|
||||
var exitCode int
|
||||
if err := g.Run(); err != nil {
|
||||
c.logger.Error("runtime error encountered", "error", err)
|
||||
c.UI.Error("Error encountered during run, refer to logs for more details.")
|
||||
var processExitError *exec.ProcessExitError
|
||||
if errors.As(err, &processExitError) {
|
||||
exitCode = processExitError.ExitCode
|
||||
} else {
|
||||
exitCode = 1
|
||||
}
|
||||
|
||||
if exitCode != 0 {
|
||||
c.logger.Error("runtime error encountered", "error", err, "exitCode", exitCode)
|
||||
c.UI.Error("Error encountered during run, refer to logs for more details.")
|
||||
}
|
||||
}
|
||||
|
||||
c.notifySystemd(systemd.SdNotifyStopping)
|
||||
|
||||
return exitCode
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue