fix: graceful shutdown with asynchronous processes - fixes #1022

This commit is contained in:
Julien Neuhart
2025-05-14 15:27:14 +02:00
parent 91757335ac
commit 66317197b6
5 changed files with 69 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package gotenbergcmd
import (
"context"
"errors"
"fmt"
"os"
"os/signal"
@@ -173,7 +174,9 @@ func Run() {
id := app.(gotenberg.Module).Descriptor().ID
err = app.Stop(gracefulShutdownCtx)
if err != nil {
if errors.Is(err, gotenberg.ErrCancelGracefulShutdownContext) {
cancel()
} else if err != nil {
return fmt.Errorf("stopping %s: %w", id, err)
}