From f4c501d3c5efb54f05d00136ef9f8af6d3549f7a Mon Sep 17 00:00:00 2001 From: postmannen Date: Fri, 2 Jul 2021 13:26:30 +0200 Subject: [PATCH] disabled main ctx cancelation --- server.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server.go b/server.go index 2eff28c..ba66147 100644 --- a/server.go +++ b/server.go @@ -285,7 +285,20 @@ func (s *server) Start() { //Block until we receive a signal sig := <-sigCh fmt.Printf("Got exit signal, terminating all processes, %v\n", sig) + + // Adding a safety function here so we can make sure that all processes + // are stopped after a given time if the context cancelation below hangs. + defer func() { + //time.Sleep(time.Second * 5) + log.Printf("error: doing a non graceful shutdown of all processes..\n") + os.Exit(1) + }() + + // TODO: The cancelation of all gracefully do not work, so adding a sleep here + // to be sure that the defered exit above are run before this cancelFunc. + time.Sleep(time.Second * 2) s.ctxCancelFunc() + fmt.Printf(" *** Done: ctxCancelFunc()\n") }