From e2e06a8f83aef8638749260c0fa635742a215755 Mon Sep 17 00:00:00 2001 From: Kevin Lindsay <19811360+kevin-lindsay-1@users.noreply.github.com> Date: Fri, 26 May 2023 12:18:40 +0000 Subject: [PATCH] feat: graceful shutdown on SIGINT and SIGTERM (#649) A second SIGINT forces shutdown, as usual. --- cmd/gotenberg.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/gotenberg.go b/cmd/gotenberg.go index be407337..c1f62991 100644 --- a/cmd/gotenberg.go +++ b/cmd/gotenberg.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "os/signal" + "syscall" "time" "github.com/gotenberg/gotenberg/v7/pkg/gotenberg" @@ -109,8 +110,8 @@ func Run() { quit := make(chan os.Signal, 1) - // We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C). - signal.Notify(quit, os.Interrupt) + // We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C) or SIGTERM (Kubernetes). + signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) // Block until we receive our signal. <-quit @@ -119,7 +120,7 @@ func Run() { defer cancel() forceQuit := make(chan os.Signal, 1) - signal.Notify(forceQuit, os.Interrupt) + signal.Notify(forceQuit, syscall.SIGINT) go func() { // In case of force quit, cancel the context.