From cbf5511b028e701cd058b1c26ed8046758462b65 Mon Sep 17 00:00:00 2001 From: Jeeyong Um Date: Thu, 19 Aug 2021 21:16:44 +0900 Subject: [PATCH] docs: fix graceful shutdown in go built-in example --- docs/tutorials/go-built-in.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/tutorials/go-built-in.md b/docs/tutorials/go-built-in.md index 81325706b..6f5c46830 100644 --- a/docs/tutorials/go-built-in.md +++ b/docs/tutorials/go-built-in.md @@ -380,14 +380,13 @@ func main() { } node.Start() - defer func() { - node.Stop() - node.Wait() - }() c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM) <-c + + node.Stop() + node.Wait() os.Exit(0) } @@ -556,14 +555,13 @@ upon receiving SIGTERM or Ctrl-C. ```go node.Start() -defer func() { - node.Stop() - node.Wait() -}() c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM) <-c + +node.Stop() +node.Wait() os.Exit(0) ```