Private GIT

Skip to content
Snippets Groups Projects
Commit f5b4c09c authored by Richard Mitchell's avatar Richard Mitchell
Browse files

Set timeouts on the HTTP server.

parent 8759908d
Branches
Tags
No related merge requests found
......@@ -6,6 +6,7 @@ import (
"log"
"net/http"
"os"
"time"
"gopkg.in/alecthomas/kingpin.v2"
"gopkg.in/yaml.v2"
......@@ -64,7 +65,12 @@ func runServer() {
prometheus.MustRegister(NewSensorCollector(namespace, bridge, cfg.SensorConfig.IgnoreTypes))
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe((*addr).String(), nil))
srv := &http.Server{
Addr: (*addr).String(),
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
}
log.Fatal(srv.ListenAndServe())
}
func main() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment