Skip to content

Commit

Permalink
[supervisor] switch lib back to use upstream ramr/go-reaper (#20322)
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh authored Oct 28, 2024
1 parent 9e8da3b commit 9442b52
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
18 changes: 11 additions & 7 deletions components/supervisor/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/gitpod-io/gitpod/common-go/process"
"github.com/gitpod-io/gitpod/supervisor/pkg/shared"
"github.com/gitpod-io/gitpod/supervisor/pkg/supervisor"
reaper "github.com/gitpod-io/go-reaper"
"github.com/prometheus/procfs"
reaper "github.com/ramr/go-reaper"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -114,18 +114,22 @@ var initCmd = &cobra.Command{
}
}()
// start the reaper to clean up zombie processes
reaperChan := make(chan reaper.Status, 10)
reaper.Start(reaper.Config{
Pid: -1,
Options: 0,
DisablePid1Check: false,
OnReap: func(pid int, wstatus syscall.WaitStatus) {
if pid != runCommand.Process.Pid {
return
StatusChannel: reaperChan,
})
go func() {
for status := range reaperChan {
if status.Pid != runCommand.Process.Pid {
continue
}
exitCode := wstatus.ExitStatus()
exitCode := status.WaitStatus.ExitStatus()
handledByReaper <- exitCode
},
})
}
}()

select {
case <-supervisorDone:
Expand Down
1 change: 1 addition & 0 deletions components/supervisor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ require (
github.com/prometheus/common v0.42.0
github.com/prometheus/procfs v0.10.1
github.com/prometheus/pushgateway v1.5.1
github.com/ramr/go-reaper v0.2.2
github.com/sirupsen/logrus v1.9.3
github.com/soheilhy/cmux v0.1.5
github.com/spf13/cobra v1.4.0
Expand Down
4 changes: 2 additions & 2 deletions components/supervisor/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9442b52

Please sign in to comment.