-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
44 lines (33 loc) · 1020 Bytes
/
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
package main
import (
"flag"
"os"
"os/signal"
"syscall"
eventhub "github.com/microsoft/azure-iothub-exporter/eventhub"
metrics "github.com/microsoft/azure-iothub-exporter/metrics"
server "github.com/microsoft/azure-iothub-exporter/server"
log "github.com/sirupsen/logrus"
)
func main() {
processArguments()
metricsQueue := metrics.NewMetricsQueue()
eventHubConnectionString := os.Getenv("EVENT_HUB_CONNECTION_STRING")
eventHubListener := eventhub.NewEventHubListener(eventHubConnectionString, metricsQueue)
eventHubListener.Run()
ioTMetricsServer := server.NewIoTMetricsServer(metricsQueue)
ioTMetricsServer.StartHttpServer()
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM)
<-signalChan
eventHubListener.Close()
}
func processArguments() {
debugLevel := flag.Bool("debug", false, "Debug log level")
flag.Parse()
if *debugLevel {
log.SetLevel(log.DebugLevel)
}
}