diff --git a/cmd/flamenco-worker/main.go b/cmd/flamenco-worker/main.go index efc6e428..67462402 100644 --- a/cmd/flamenco-worker/main.go +++ b/cmd/flamenco-worker/main.go @@ -144,14 +144,16 @@ func shutdown() { done := make(chan struct{}) go func() { if w != nil { - shutdownCtx, cancelFunc := context.WithTimeout(context.Background(), 3*time.Second) - defer cancelFunc() - w.SignOff(shutdownCtx) w.Close() listener.Wait() if err := buffer.Close(); err != nil { log.Error().Err(err).Msg("closing upstream task buffer") } + + // Sign off as the last step. Any flushes should happen while we're still signed on. + signoffCtx, cancelFunc := context.WithTimeout(context.Background(), 3*time.Second) + defer cancelFunc() + w.SignOff(signoffCtx) } close(done) }() diff --git a/internal/worker/worker.go b/internal/worker/worker.go index a2f8151d..9d45e8db 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -63,5 +63,4 @@ func (w *Worker) Close() { log.Debug().Msg("worker gracefully shutting down") close(w.doneChan) w.doneWg.Wait() - log.Debug().Msg("worker shut down") }