From 7211d97fd552c015737d8d7c585313509657d5ab Mon Sep 17 00:00:00 2001 From: Nathan Date: Sun, 15 Jan 2023 04:03:22 +0000 Subject: [PATCH] signal wait to block for end --- main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main.go b/main.go index 7d545fe..b50d1e1 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,8 @@ import ( _ "image/jpeg" "log" "os" + "os/signal" + "syscall" "time" rgbmatrix "gitea.wagshome.duckdns.org/publicWagsHome/go-rpi-rgb-led-matrix" @@ -76,6 +78,18 @@ func main() { log.Println("making animator") go animator(tk, mqMessages) log.Println("I guess I'm at the end") + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) + done := make(chan bool, 1) + go func() { + sig := <-sigs + fmt.Println() + fmt.Println(sig) + done <- true + }() + fmt.Println("awaiting signal") + <-done + fmt.Println("exiting") } func listener(mqMessages chan mqtt.Message) {