summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/websocket.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/websocket.go b/tools/websocket.go
index 575bcd5..fc76d56 100644
--- a/tools/websocket.go
+++ b/tools/websocket.go
@@ -13,6 +13,7 @@ import (
"net/url"
"os"
"os/signal"
+ "syscall"
"github.com/gorilla/websocket"
)
@@ -31,6 +32,8 @@ func main() {
log.Fatal(err)
}
defer c.Close()
+
+ Await(syscall.SIGTERM, syscall.SIGINT)
}
func getURL() url.URL {
@@ -45,3 +48,12 @@ func getURL() url.URL {
return *maybeURL
}
+
+func Await(signals ...os.Signal) {
+ listener := make(chan os.Signal, 1)
+ signal.Notify(listener, signals...)
+ defer signal.Stop(listener)
+
+ sig := <-listener
+ log.Printf("Received OS signal '%v'\n", sig)
+}