diff --git a/ee/desktop/runner/runner.go b/ee/desktop/runner/runner.go index bf73a8405..1af0903c3 100644 --- a/ee/desktop/runner/runner.go +++ b/ee/desktop/runner/runner.go @@ -29,6 +29,7 @@ import ( "github.com/kolide/launcher/ee/desktop/user/client" "github.com/kolide/launcher/ee/desktop/user/menu" "github.com/kolide/launcher/ee/desktop/user/notify" + "github.com/kolide/launcher/ee/gowrapper" "github.com/kolide/launcher/ee/presencedetection" "github.com/kolide/launcher/ee/ui/assets" "github.com/kolide/launcher/pkg/backoff" @@ -184,14 +185,19 @@ func New(k types.Knapsack, messenger runnerserver.Messenger, opts ...desktopUser } runner.runnerServer = rs - go func() { + gowrapper.Go(context.TODO(), runner.slogger, func() { if err := runner.runnerServer.Serve(); err != nil && !errors.Is(err, http.ErrServerClosed) { runner.slogger.Log(context.TODO(), slog.LevelError, "running monitor server", "err", err, ) } - }() + }, func(err any) { + runner.slogger.Log(context.TODO(), slog.LevelError, + "exiting after monitor server panic", + "err", err, + ) + }) if runtime.GOOS == "darwin" { runner.osVersion, err = osversion() @@ -309,10 +315,15 @@ func (r *DesktopUsersProcessesRunner) DetectPresence(reason string, interval tim // killDesktopProcesses kills any existing desktop processes func (r *DesktopUsersProcessesRunner) killDesktopProcesses(ctx context.Context) { wgDone := make(chan struct{}) - go func() { + gowrapper.Go(context.TODO(), r.slogger, func() { defer close(wgDone) r.procsWg.Wait() - }() + }, func(err any) { + r.slogger.Log(context.TODO(), slog.LevelError, + "exiting after wait group panic", + "err", err, + ) + }) shutdownRequestCount := 0 for uid, proc := range r.uidProcs { @@ -785,7 +796,7 @@ func (r *DesktopUsersProcessesRunner) addProcessTrackingRecordForUser(uid string // The wait group is needed to prevent races. func (r *DesktopUsersProcessesRunner) waitOnProcessAsync(uid string, proc *os.Process) { r.procsWg.Add(1) - go func(username string, proc *os.Process) { + gowrapper.Go(context.TODO(), r.slogger, func() { defer r.procsWg.Done() // waiting here gives the parent a chance to clean up state, err := proc.Wait() @@ -798,7 +809,14 @@ func (r *DesktopUsersProcessesRunner) waitOnProcessAsync(uid string, proc *os.Pr "state", state, ) } - }(uid, proc) + }, func(err any) { + r.slogger.Log(context.TODO(), slog.LevelError, + "exiting after process wait panic", + "err", err, + "uid", uid, + "pid", proc.Pid, + ) + }) } // determineExecutablePath returns DesktopUsersProcessesRunner.executablePath if it is set,