cmd: introduce control socket & subcommand

Move pprof debugging there.
This commit is contained in:
Christian Schwarz
2017-09-17 23:54:23 +02:00
parent aea62a9d85
commit 3eaba92025
5 changed files with 222 additions and 19 deletions

View File

@ -12,8 +12,6 @@ package cmd
import (
"github.com/spf13/cobra"
"net/http"
_ "net/http/pprof"
)
type Logger interface {
@ -33,24 +31,9 @@ var RootCmd = &cobra.Command{
var rootArgs struct {
configFile string
httpPprof string
}
func init() {
//cobra.OnInitialize(initConfig)
RootCmd.PersistentFlags().StringVar(&rootArgs.configFile, "config", "", "config file path")
RootCmd.PersistentFlags().StringVar(&rootArgs.httpPprof, "debug.pprof.http", "", "run pprof http server on given port")
}
func initConfig() {
// CPU profiling
if rootArgs.httpPprof != "" {
go func() {
http.ListenAndServe(rootArgs.httpPprof, nil)
}()
}
return
}