feat: graceful shutdown on SIGINT and SIGTERM (#649)

A second SIGINT forces shutdown, as usual.
This commit is contained in:
Kevin Lindsay
2023-05-26 12:18:40 +00:00
committed by GitHub
parent 8402f73d52
commit e2e06a8f83

View File

@@ -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.