git » dnss » commit a90cf72

Replace profile module with explicit, more targeted code

author Alberto Bertogli
2015-09-11 13:06:57 UTC
committer Alberto Bertogli
2015-09-11 13:06:57 UTC
parent 2958a6aefd2da7f182c86cbee1fbb59d4860f632

Replace profile module with explicit, more targeted code

dnss.go +12 -3

diff --git a/dnss.go b/dnss.go
index e477d1c..44404e0 100644
--- a/dnss.go
+++ b/dnss.go
@@ -5,6 +5,10 @@ import (
 	"sync"
 	"time"
 
+	// Register pprof handlers for monitoring and debugging.
+	"net/http"
+	_ "net/http/pprof"
+
 	"github.com/golang/glog"
 
 	// Make GRPC log to glog.
@@ -12,7 +16,6 @@ import (
 
 	"blitiri.com.ar/go/dnss/dnstogrpc"
 	"blitiri.com.ar/go/dnss/grpctodns"
-	"blitiri.com.ar/go/profile"
 )
 
 var (
@@ -39,6 +42,8 @@ var (
 
 	logFlushEvery = flag.Duration("log_flush_every", 30*time.Second,
 		"how often to flush logs")
+	monitoringListenAddr = flag.String("monitoring_listen_addr", "",
+		"address to listen on for monitoring HTTP requests")
 )
 
 func flushLogs() {
@@ -53,10 +58,14 @@ func main() {
 
 	flag.Parse()
 
-	profile.Init()
-
 	go flushLogs()
 
+	if *monitoringListenAddr != "" {
+		glog.Infof("Monitoring HTTP server listening on %s",
+			*monitoringListenAddr)
+		go http.ListenAndServe(*monitoringListenAddr, nil)
+	}
+
 	if !*enableDNStoGRPC && !*enableGRPCtoDNS {
 		glog.Fatal(
 			"Error: pass --enable_dns_to_grpc or --enable_grpc_to_dns")