mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-08 00:22:14 +01:00
feat: graceful shutdown on SIGINT and SIGTERM (#649)
A second SIGINT forces shutdown, as usual.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gotenberg/gotenberg/v7/pkg/gotenberg"
|
"github.com/gotenberg/gotenberg/v7/pkg/gotenberg"
|
||||||
@@ -109,8 +110,8 @@ func Run() {
|
|||||||
|
|
||||||
quit := make(chan os.Signal, 1)
|
quit := make(chan os.Signal, 1)
|
||||||
|
|
||||||
// We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C).
|
// We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C) or SIGTERM (Kubernetes).
|
||||||
signal.Notify(quit, os.Interrupt)
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
|
||||||
// Block until we receive our signal.
|
// Block until we receive our signal.
|
||||||
<-quit
|
<-quit
|
||||||
@@ -119,7 +120,7 @@ func Run() {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
forceQuit := make(chan os.Signal, 1)
|
forceQuit := make(chan os.Signal, 1)
|
||||||
signal.Notify(forceQuit, os.Interrupt)
|
signal.Notify(forceQuit, syscall.SIGINT)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// In case of force quit, cancel the context.
|
// In case of force quit, cancel the context.
|
||||||
|
|||||||
Reference in New Issue
Block a user