Skip to content

Commit 867e3e4

Browse files
committed
Pass command as parameter into processWaitQuit
Signed-off-by: Tom Wieczorek <[email protected]>
1 parent 5a6b46a commit 867e3e4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pkg/supervisor/supervisor.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ const k0sManaged = "_K0S_MANAGED=yes"
5454

5555
// processWaitQuit waits for a process to exit or a shut down signal
5656
// returns true if shutdown is requested
57-
func (s *Supervisor) processWaitQuit(ctx context.Context) bool {
57+
func (s *Supervisor) processWaitQuit(ctx context.Context, cmd *exec.Cmd) bool {
5858
waitresult := make(chan error)
5959
go func() {
60-
waitresult <- s.cmd.Wait()
60+
waitresult <- cmd.Wait()
6161
}()
6262

6363
defer os.Remove(s.PidFile)
@@ -66,7 +66,7 @@ func (s *Supervisor) processWaitQuit(ctx context.Context) bool {
6666
case <-ctx.Done():
6767
for {
6868
s.log.Debug("Requesting graceful termination")
69-
if err := requestGracefulTermination(s.cmd.Process); err != nil {
69+
if err := requestGracefulTermination(cmd.Process); err != nil {
7070
if errors.Is(err, os.ErrProcessDone) {
7171
s.log.Info("Failed to request graceful termination: process has already terminated")
7272
} else {
@@ -91,7 +91,7 @@ func (s *Supervisor) processWaitQuit(ctx context.Context) bool {
9191
if err != nil {
9292
s.log.WithError(err).Warn("Failed to wait for process")
9393
} else {
94-
s.log.Warnf("Process exited: ", s.cmd.ProcessState)
94+
s.log.Warnf("Process exited: ", cmd.ProcessState)
9595
}
9696
}
9797
return false
@@ -182,7 +182,7 @@ func (s *Supervisor) Supervise() error {
182182
s.log.Infof("Restarted (%d)", restarts)
183183
}
184184
restarts++
185-
if s.processWaitQuit(ctx) {
185+
if s.processWaitQuit(ctx, s.cmd) {
186186
return
187187
}
188188
}

0 commit comments

Comments
 (0)