Skip to content

Commit

Permalink
restart if pktmon server closes
Browse files Browse the repository at this point in the history
  • Loading branch information
matmerr committed Sep 30, 2024
1 parent cbe28cf commit db5b127
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pkg/plugin/windows/pktmon/pktmon_plugin_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,13 @@ func (p *Plugin) Start(ctx context.Context) error {
return ErrNilEnricher
}

errChan := make(chan error)
go func() {
err := p.RunPktMonServer(ctx)
if err != nil {
p.l.Error("pktmon server exited", zap.Error(err))
}
errChan <- err
}()

err := p.SetupStream()
Expand All @@ -143,14 +145,18 @@ func (p *Plugin) Start(ctx context.Context) error {
}

// run the getflows loop
for {
err := p.GetFlow(ctx)
if _, ok := status.FromError(err); ok {
p.l.Error("failed to get flow, retriable:", zap.Error(err))
continue
go func() {
for {
err := p.GetFlow(ctx)
if _, ok := status.FromError(err); ok {
p.l.Error("failed to get flow, retriable:", zap.Error(err))
continue
}
errChan <- fmt.Errorf("failed to get flow, unrecoverable: %w", err)
}
return fmt.Errorf("failed to get flow, unrecoverable: %w", err)
}
}()

return <-errChan
}

func (p *Plugin) SetupStream() error {
Expand Down

0 comments on commit db5b127

Please sign in to comment.