@@ -30,6 +30,8 @@ func main() {
30
30
var (
31
31
Name = serviceName
32
32
listenAddress = flag .String ("web.listen-address" , ":9479" , "Address to listen on for web interface and telemetry." )
33
+ tlsCertFile = flag .String ("tls.certfile" , "" , "TLS certs file if you want to use tls instead of http" )
34
+ tlsKeyFile = flag .String ("tls.keyfile" , "" , "TLS key file if you want to use tls instead of http" )
33
35
metricsPath = flag .String ("web.telemetry-path" , "/metrics" , "Path under which to expose metrics." )
34
36
beatURI = flag .String ("beat.uri" , "http://localhost:5066" , "HTTP API address of beat." )
35
37
beatTimeout = flag .Duration ("beat.timeout" , 10 * time .Second , "Timeout for trying to get stats from beat." )
@@ -134,12 +136,22 @@ beatdiscovery:
134
136
}()
135
137
136
138
log .Info ("Starting listener" )
137
- if err := http .ListenAndServe (* listenAddress , nil ); err != nil {
139
+ if * tlsCertFile != "" && * tlsKeyFile != "" {
140
+ if err := http .ListenAndServeTLS (* listenAddress , * tlsCertFile , * tlsKeyFile , nil ); err != nil {
138
141
139
- log .WithFields (log.Fields {
140
- "err" : err ,
141
- }).Errorf ("http server quit with error: %v" , err )
142
+ log .WithFields (log.Fields {
143
+ "err" : err ,
144
+ }).Errorf ("tls server quit with error: %v" , err )
142
145
146
+ }
147
+ } else {
148
+ if err := http .ListenAndServe (* listenAddress , nil ); err != nil {
149
+
150
+ log .WithFields (log.Fields {
151
+ "err" : err ,
152
+ }).Errorf ("http server quit with error: %v" , err )
153
+
154
+ }
143
155
}
144
156
log .Info ("Listener exited" )
145
157
}()
0 commit comments