Skip to content

Commit

Permalink
add end reason to egress info
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 committed Aug 8, 2024
1 parent e7b3b9a commit fab685b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
5 changes: 1 addition & 4 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ func (h *Handler) Run() {
}

func (h *Handler) Kill() {
// kill signal received
h.conf.Info.Details = "service terminated by deployment"

<-h.initialized.Watch()
h.controller.SendEOS(context.Background())
h.controller.SendEOS(context.Background(), "handler killed")
}
2 changes: 1 addition & 1 deletion pkg/handler/handler_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ func (h *Handler) StopEgress(ctx context.Context, _ *livekit.StopEgressRequest)
return nil, errors.ErrEgressNotFound
}

h.controller.SendEOS(ctx)
h.controller.SendEOS(ctx, "StopEgress API")
return (*livekit.EgressInfo)(h.controller.Info), nil
}
10 changes: 6 additions & 4 deletions pkg/pipeline/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package pipeline

import (
"context"
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -205,7 +206,7 @@ func (c *Controller) Run(ctx context.Context) *info.EgressInfo {
// close when room ends
go func() {
<-c.src.EndRecording()
c.SendEOS(ctx)
c.SendEOS(ctx, "source closed")
}()

// wait until room is ready
Expand Down Expand Up @@ -373,7 +374,7 @@ func (c *Controller) removeSink(ctx context.Context, url string, streamErr error
if streamErr != nil {
return streamErr
} else {
c.SendEOS(ctx)
c.SendEOS(ctx, "all streams removed")
return nil
}
}
Expand All @@ -387,7 +388,7 @@ func (c *Controller) removeSink(ctx context.Context, url string, streamErr error
return c.streamBin.RemoveStream(url)
}

func (c *Controller) SendEOS(ctx context.Context) {
func (c *Controller) SendEOS(ctx context.Context, reason string) {
ctx, span := tracer.Start(ctx, "Pipeline.SendEOS")
defer span.End()

Expand All @@ -396,6 +397,7 @@ func (c *Controller) SendEOS(ctx context.Context) {
c.limitTimer.Stop()
}

c.Info.Details = fmt.Sprintf("end reason: %s", reason)
switch c.Info.Status {
case livekit.EgressStatus_EGRESS_STARTING:
c.Info.SetAborted(info.MsgStoppedBeforeStarted)
Expand Down Expand Up @@ -507,7 +509,7 @@ func (c *Controller) startSessionLimitTimer(ctx context.Context) {
c.Info.SetLimitReached()
}
if c.playing.IsBroken() {
c.SendEOS(ctx)
c.SendEOS(ctx, "time limit reached")
} else {
c.p.Stop()
}
Expand Down
7 changes: 0 additions & 7 deletions pkg/pipeline/source/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,6 @@ func (s *WebSource) launchChrome(ctx context.Context, p *config.PipelineConfig,

case *runtime.EventExceptionThrown:
logChrome("exception", ev)
if s.info.Details == "" {
if exceptionDetails := ev.ExceptionDetails; exceptionDetails != nil {
if exception := exceptionDetails.Exception; exception != nil {
s.info.Details = fmt.Sprintf("Uncaught chrome exception: %s", exception.Description)
}
}
}
}
})

Expand Down

0 comments on commit fab685b

Please sign in to comment.