This repository was archived by the owner on Mar 24, 2022. It is now read-only.
forked from cloudfoundry-attic/datadog-firehose-nozzle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
58 lines (46 loc) · 1.47 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
package main
import (
"flag"
"log"
"os"
"os/signal"
"runtime"
"runtime/pprof"
"syscall"
"github.com/pivotal-cf-experimental/opentsdb-firehose-nozzle/nozzleconfig"
"github.com/pivotal-cf-experimental/opentsdb-firehose-nozzle/opentsdbfirehosenozzle"
"github.com/pivotal-cf-experimental/opentsdb-firehose-nozzle/uaatokenfetcher"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
configFilePath := flag.String("config", "config/opentsdb-firehose-nozzle.json", "Location of the nozzle config json file")
flag.Parse()
config, err := nozzleconfig.Parse(*configFilePath)
if err != nil {
log.Fatalf("Error parsing config: %s", err.Error())
}
tokenFetcher := &uaatokenfetcher.UAATokenFetcher{
UaaUrl: config.UAAURL,
Username: config.Username,
Password: config.Password,
InsecureSSLSkipVerify: config.InsecureSSLSkipVerify,
}
threadDumpChan := registerGoRoutineDumpSignalChannel()
defer close(threadDumpChan)
go dumpGoRoutine(threadDumpChan)
opentsdbNozzle := opentsdbfirehosenozzle.NewOpenTSDBFirehoseNozzle(config, tokenFetcher)
opentsdbNozzle.Start()
}
func registerGoRoutineDumpSignalChannel() chan os.Signal {
threadDumpChan := make(chan os.Signal, 1)
signal.Notify(threadDumpChan, syscall.SIGUSR1)
return threadDumpChan
}
func dumpGoRoutine(dumpChan chan os.Signal) {
for range dumpChan {
goRoutineProfiles := pprof.Lookup("goroutine")
if goRoutineProfiles != nil {
goRoutineProfiles.WriteTo(os.Stdout, 2)
}
}
}