Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display more context on binary exit #114

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pkg/deployer/baremetal/component/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,20 @@ func runBinary(ctx context.Context, binary string, args []string, logDir string,
cmd.Stdout = outputFileWriter
cmd.Stderr = outputFileWriter

logger.V(3).Infof("run binary '%s' with args: '%v', log: '%s', pid: '%s'", binary, args, logDir, pidDir)

if err := cmd.Start(); err != nil {
return err
}

pid := strconv.Itoa(cmd.Process.Pid)
logger.V(3).Infof("run binary '%s' with args: '%v', log: '%s', pid: '%s'", binary, args, logDir, pid)

pidFile := path.Join(pidDir, "pid")
f, err := os.Create(pidFile)
if err != nil {
return err
}

_, err = f.Write([]byte(strconv.Itoa(cmd.Process.Pid)))
_, err = f.Write([]byte(pid))
if err != nil {
return err
}
Expand All @@ -112,7 +113,9 @@ func runBinary(ctx context.Context, binary string, args []string, logDir string,
}
}
}
logger.Errorf("binary '%s' exited with error: %v", binary, err)
logger.Errorf("binary '%s' (pid '%s') exited with error: %v. Log at '%s'", binary, pid, err, logDir)
logger.Errorf("args: '%v'", args)
_ = outputFileWriter.Flush()
}
}()

Expand Down
Loading