1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-11-23 21:44:44 +02:00

Gracefully shutdown agent (#3895)

This commit is contained in:
6543
2024-07-13 16:06:20 -07:00
committed by GitHub
parent d1c0f781f1
commit 30cd800110
8 changed files with 273 additions and 95 deletions

View File

@@ -105,7 +105,11 @@ func (r *Runtime) Run(runnerCtx context.Context) error {
}
defer func() {
if err := r.engine.DestroyWorkflow(runnerCtx, r.spec, r.taskUUID); err != nil {
ctx := runnerCtx //nolint:contextcheck
if ctx.Err() != nil {
ctx = GetShutdownCtx()
}
if err := r.engine.DestroyWorkflow(ctx, r.spec, r.taskUUID); err != nil {
logger.Error().Err(err).Msg("could not destroy engine")
}
}()