Worker: cleanly sign off after flushing buffer
When running the Worker with the `-flush` CLI argument, actually sign off from the Manager before shutting down.
This commit is contained in:
parent
0697f71b62
commit
47e517a3a5
@ -119,6 +119,7 @@ func main() {
|
|||||||
|
|
||||||
if cliArgs.flush {
|
if cliArgs.flush {
|
||||||
log.Info().Msg("upstream buffer flushed, shutting down")
|
log.Info().Msg("upstream buffer flushed, shutting down")
|
||||||
|
worker.SignOff(workerCtx, log.Logger, client)
|
||||||
workerCtxCancel()
|
workerCtxCancel()
|
||||||
shutdown()
|
shutdown()
|
||||||
return
|
return
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"git.blender.org/flamenco/pkg/api"
|
"git.blender.org/flamenco/pkg/api"
|
||||||
@ -40,13 +41,17 @@ func (w *Worker) SignOff(ctx context.Context) {
|
|||||||
|
|
||||||
logger.Info().Msg("signing off at Manager")
|
logger.Info().Msg("signing off at Manager")
|
||||||
|
|
||||||
resp, err := w.client.SignOffWithResponse(ctx)
|
SignOff(ctx, logger, w.client)
|
||||||
if err != nil {
|
}
|
||||||
|
|
||||||
|
// SignOff sends a signoff request to the Manager.
|
||||||
|
// Any error is logged but not returned.
|
||||||
|
func SignOff(ctx context.Context, logger zerolog.Logger, client FlamencoClient) {
|
||||||
|
resp, err := client.SignOffWithResponse(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
logger.Error().Err(err).Msg("unable to sign off at Manager")
|
logger.Error().Err(err).Msg("unable to sign off at Manager")
|
||||||
return
|
case resp.JSONDefault != nil:
|
||||||
}
|
|
||||||
if resp.JSONDefault != nil {
|
|
||||||
logger.Error().Interface("error", resp.JSONDefault).Msg("error received when signing off at Manager")
|
logger.Error().Interface("error", resp.JSONDefault).Msg("error received when signing off at Manager")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user