Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional pprof http endpoint immediately on startup. #9903

Merged
merged 1 commit into from May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions cmd/influxd/run/command.go
Expand Up @@ -7,6 +7,8 @@ import (
"io"
"io/ioutil"
"log"
"net/http"
_ "net/http/pprof"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -92,6 +94,13 @@ func (cmd *Command) Run(args ...string) error {
cmd.Logger = logger.New(cmd.Stderr)
}

// Attempt to run pprof on :6060 before startup if debug pprof enabled.
if config.HTTPD.DebugPprofEnabled {
runtime.SetBlockProfileRate(int(1 * time.Second))
runtime.SetMutexProfileFraction(1)
go func() { http.ListenAndServe("localhost:6060", nil) }()
}

// Print sweet InfluxDB logo.
if !config.Logging.SuppressLogo && logger.IsTerminal(cmd.Stdout) {
fmt.Fprint(cmd.Stdout, logo)
Expand Down
4 changes: 4 additions & 0 deletions etc/config.sample.toml
Expand Up @@ -241,6 +241,10 @@
# troubleshooting and monitoring.
# pprof-enabled = true

# Enables a pprof endpoint that binds to localhost:6060 immediately on startup.
# This is only needed to debug startup issues.
# debug-pprof-enabled = false

# Determines whether HTTPS is enabled.
# https-enabled = false

Expand Down
2 changes: 2 additions & 0 deletions services/httpd/config.go
Expand Up @@ -24,6 +24,7 @@ type Config struct {
LogEnabled bool `toml:"log-enabled"`
WriteTracing bool `toml:"write-tracing"`
PprofEnabled bool `toml:"pprof-enabled"`
DebugPprofEnabled bool `toml:"debug-pprof-enabled"`
HTTPSEnabled bool `toml:"https-enabled"`
HTTPSCertificate string `toml:"https-certificate"`
HTTPSPrivateKey string `toml:"https-private-key"`
Expand All @@ -44,6 +45,7 @@ func NewConfig() Config {
BindAddress: DefaultBindAddress,
LogEnabled: true,
PprofEnabled: true,
DebugPprofEnabled: false,
HTTPSEnabled: false,
HTTPSCertificate: "/etc/ssl/influxdb.pem",
MaxRowLimit: 0,
Expand Down