Skip to content

Commit

Permalink
streamer: make the call to Stop only for the path that needs it
Browse files Browse the repository at this point in the history
streamer: add more info prints to the graceful functionality
  • Loading branch information
Wessie committed May 29, 2024
1 parent d4cd06c commit 75dbdb9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion streamer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func Execute(ctx context.Context, cfg config.Config) error {
if err != nil {
return err
}
defer streamer.Stop(context.Background(), true)

// setup a http server for our RPC API
srv, err := NewGRPCServer(ctx, cfg, store, queue, cfg.IRC, streamer)
Expand Down Expand Up @@ -62,6 +61,7 @@ func Execute(ctx context.Context, cfg config.Config) error {
case <-ctx.Done():
return nil
case err = <-errCh:
streamer.Stop(ctx, true)
return err
}
}
3 changes: 3 additions & 0 deletions streamer/streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (s *Streamer) checkFDStore(ctx context.Context, store *fdstore.Store) {
}

if len(connEntries) > 0 {
zerolog.Ctx(ctx).Info().Msg("recovered an icecast connection")
// grab the first entry
conn = connEntries[0].Conn
// close the rest
Expand Down Expand Up @@ -132,6 +133,7 @@ func (s *Streamer) checkFDStore(ctx context.Context, store *fdstore.Store) {
var entries []StreamTrack

if current != nil {
zerolog.Ctx(ctx).Info().Msg("recovered the current song")
entries = append(entries, StreamTrack{
QueueEntry: currentEntry,
Audio: current,
Expand All @@ -155,6 +157,7 @@ func (s *Streamer) checkFDStore(ctx context.Context, store *fdstore.Store) {
continue
}

zerolog.Ctx(ctx).Info().Msg("recovered an encoder song")
entries = append(entries, StreamTrack{
QueueEntry: queueEntry,
Audio: reader,
Expand Down

0 comments on commit 75dbdb9

Please sign in to comment.