Skip to content
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
23 changes: 20 additions & 3 deletions helper/util/restart_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import (
"syscall"
"time"

"github.com/loft-sh/devspace/helper/util/stderrlog"
"github.com/loft-sh/devspace/pkg/devspace/build/builder/restart"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/util/wait"
)

type containerRestarter struct {
Expand Down Expand Up @@ -69,8 +71,23 @@ func (*containerRestarter) RestartContainer() error {
}

// kill the process group
_ = syscall.Kill(-pgid, syscall.SIGINT)
time.Sleep(2000)
_ = syscall.Kill(-pgid, syscall.SIGKILL)
procPath := "/proc/" + strconv.Itoa(pgid)

for _, sig := range []syscall.Signal{syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL} {
stderrlog.Infof("Sending %s signal...", sig.String())
err = syscall.Kill(-pgid, sig)
if err != nil {
return nil
}
err = wait.PollImmediate(time.Second, 5*time.Second, func() (done bool, err error) {
_, err = os.Stat(procPath)
return os.IsNotExist(err), nil
})
if err == nil {
return nil
}
}

stderrlog.Errorf("Timeout waiting for the process to terminate")
return nil
}