From 9d732fb01a2ef320a43785200098dd64693f357b Mon Sep 17 00:00:00 2001 From: claudemiro Date: Thu, 1 Sep 2016 21:03:29 -0300 Subject: [PATCH] Added option to enable pprof. --- README.md | 3 ++- functional/functional-config.json | 3 ++- ipe/config-example.json | 1 + ipe/config.go | 1 + ipe/ipe.go | 4 ++++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 29d03ea..1dd2d6e 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,8 @@ $ go install github.com/dimiro1/ipe ```javascript { "Host": ":8080", // Required - "SSL": false, // Required but can be false + "SSL": false, // Not Required, default is false + "Profiling": false, // Mount pprof at /debug. Not Required, default is false "SSLHost": ":4433", // Required if SSL is true "SSLKeyFile": "A key.pem file", // Required if SSL is true "SSLCertFile": "A cert.pem file", // Required if SSL is true diff --git a/functional/functional-config.json b/functional/functional-config.json index 08e9bcf..fc88457 100644 --- a/functional/functional-config.json +++ b/functional/functional-config.json @@ -1,6 +1,7 @@ { "Host": ":8080", - "Encrypted": false, + "SSL": false, + "Profiling": true, "SSLHost": ":8090", "SSLKeyFile": "key.pem", "SSLCertFile": "cert.pem", diff --git a/ipe/config-example.json b/ipe/config-example.json index f209d5f..91e4694 100644 --- a/ipe/config-example.json +++ b/ipe/config-example.json @@ -1,6 +1,7 @@ { "Host": ":8080", "SSL": false, + "Profiling": false, "SSLHost": ":4433", "SSLKeyFile": "A key.pem file", "SSLCertFile": "A cert.pem file", diff --git a/ipe/config.go b/ipe/config.go index 6837761..ce413f9 100644 --- a/ipe/config.go +++ b/ipe/config.go @@ -9,6 +9,7 @@ type configFile struct { Host string // The host, eg: :8080 will start on 0.0.0.0:8080 User string SSL bool + Profiling bool SSLHost string SSLKeyFile string SSLCertFile string diff --git a/ipe/ipe.go b/ipe/ipe.go index 5e45c1c..b2030f1 100644 --- a/ipe/ipe.go +++ b/ipe/ipe.go @@ -59,6 +59,10 @@ func Start(filename string) { r.Get("/apps/:app_id/channels/:channel_name/users", (&getChannelUsersHandler{db}).ServeHTTP) }) + if conf.Profiling { + r.Mount("/debug", middleware.Profiler()) + } + if conf.SSL { go func() { log.Infof("Starting HTTPS service on %s ...", conf.SSLHost)