-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
83 lines (54 loc) · 1.76 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"fmt"
"github.com/fatih/color"
"github.com/root27/slacknotifyMQ/controllers"
"os"
"os/signal"
"syscall"
)
var (
welcomeMessage = `
_____ _ _ _ _ _ _ __ __ __ ____
/ ____| | | | | \ | | | | (_)/ _| | \/ |/ __ \
| (___ | | __ _ ___| | _| \| | ___ | |_ _| |_ _ _| \ / | | | |
\___ \| |/ /|/ __| |/ / . |/ _ \| __| | _| | | | |\/| | | | |
____) | | (_| | (__| <| |\ | (_) | |_| | | | |_| | | | | |__| |
|_____/|_|\__,_|\___|_|\_\_| \_|\___/ \__|_|_| \__, |_| |_|\___\_\
__/ |
|___/
SlackNotifyMQ - Bringing your RabbitMQ alerts to Slack!
`
)
func main() {
fmt.Println(welcomeMessage)
var url string
fmt.Print(color.YellowString("Enter the rabbitMQ host address (default: amqp://guest:guest@localhost:5672) : "))
fmt.Scanln(&url)
if url == "" {
url = "amqp://guest:guest@localhost:5672/"
}
var queueName string
fmt.Print(color.YellowString("Enter the rabbitMQ queue name: "))
fmt.Scanln(&queueName)
var slackToken string
fmt.Print(color.YellowString("Enter the token of your slack: "))
fmt.Scanln(&slackToken)
var slackChannel string
fmt.Print(color.YellowString("Enter the channel ID of slack that notifications will be sent to (e.g. #general) : "))
fmt.Scanln(&slackChannel)
s := lib.SlackNotify{
RabbitHost: url,
RabbitQueue: queueName,
SlackToken: slackToken,
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()
}