diff --git a/main.go b/main.go index fc11c4c..acbcade 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,9 @@ import ( "fmt" "github.com/fatih/color" "github.com/root27/slacknotifyMQ/controllers" + "os" + "os/signal" + "syscall" ) var ( @@ -65,6 +68,16 @@ func main() { SlackChannel: slackChannel, } + stopChan := make(chan os.Signal, 1) + + signal.Notify(stopChan, os.Interrupt, syscall.SIGTERM) + + go func() { + <-stopChan + fmt.Println(color.RedString("Notifier Stopped")) + os.Exit(0) + }() + s.HandleRabbit() }