about summary refs log tree commit diff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/bot/main.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/cmd/bot/main.go b/cmd/bot/main.go
index 51661e8..0f241c9 100644
--- a/cmd/bot/main.go
+++ b/cmd/bot/main.go
@@ -4,6 +4,8 @@ import (
 	"jinx/pkg/bot"
 	"log"
 	"os"
+	"os/signal"
+	"syscall"
 )
 
 func main() {
@@ -12,7 +14,18 @@ func main() {
 		log.Fatal("`BOT_TOKEN` is not set.")
 	}
 
-	if err := bot.Start(token); err != nil {
+	b, err := bot.Start(token)
+	if err != nil {
+		panic(err)
+	}
+
+	c := make(chan os.Signal, 2)
+	signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
+
+	s := <-c
+	log.Printf("received signal: %s! stopping...", s)
+
+	if err := b.Stop(); err != nil {
 		panic(err)
 	}
 }