diff --git a/phases.go b/phases.go index 7650e14..1b6a298 100644 --- a/phases.go +++ b/phases.go @@ -255,6 +255,19 @@ func (this *environment) phase70_5Trimming() bool { } func (this *environment) phase80Shutdown() bool { + ctx, done := context.WithTimeout( + context.Background(), + defaul(this.timing.shutdownTimeout.Load(), defaultShutdownTimeout)) + defer done() + go func() { + <- ctx.Done() + if errors.Is(context.Cause(ctx), context.DeadlineExceeded) { + log.Println("XXX (80) shutdown timeout expired, performing emergency halt") + log.Printf("====== [%s] END =======", this.name) + os.Exit(1) + } + }() + cause := context.Cause(this.ctx) if cause != nil { log.Println("XXX (80) shutting down because:", cause)