Merge pull request #470 from surajssd/enable-cpu-profiling
Add flag --cpu-profile to enable pprof
This commit is contained in:
commit
d6bf131c07
2 changed files with 18 additions and 0 deletions
|
@ -9,6 +9,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"runtime/pprof"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/containers/storage/pkg/reexec"
|
"github.com/containers/storage/pkg/reexec"
|
||||||
"github.com/kubernetes-incubator/cri-o/server"
|
"github.com/kubernetes-incubator/cri-o/server"
|
||||||
|
@ -210,6 +212,10 @@ func main() {
|
||||||
Name: "cni-plugin-dir",
|
Name: "cni-plugin-dir",
|
||||||
Usage: "CNI plugin binaries directory",
|
Usage: "CNI plugin binaries directory",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "cpu-profile",
|
||||||
|
Usage: "set the CPU profile file path",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(cli.FlagsByName(app.Flags))
|
sort.Sort(cli.FlagsByName(app.Flags))
|
||||||
|
@ -258,6 +264,15 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Action = func(c *cli.Context) error {
|
app.Action = func(c *cli.Context) error {
|
||||||
|
if cp := c.GlobalString("cpu-profile"); cp != "" {
|
||||||
|
f, err := os.Create(cp)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid --cpu-profile value %q", err)
|
||||||
|
}
|
||||||
|
pprof.StartCPUProfile(f)
|
||||||
|
defer pprof.StopCPUProfile()
|
||||||
|
}
|
||||||
|
|
||||||
config := c.App.Metadata["config"].(*server.Config)
|
config := c.App.Metadata["config"].(*server.Config)
|
||||||
|
|
||||||
if !config.SELinux {
|
if !config.SELinux {
|
||||||
|
|
|
@ -110,6 +110,9 @@ ocid is meant to provide an integration path between OCI conformant runtimes and
|
||||||
**--cni-plugin-dir**=""
|
**--cni-plugin-dir**=""
|
||||||
CNI plugin binaries directory (default: "/opt/cni/bin/")
|
CNI plugin binaries directory (default: "/opt/cni/bin/")
|
||||||
|
|
||||||
|
**--cpu-profile**
|
||||||
|
Set the CPU profile file path
|
||||||
|
|
||||||
**--version, -v**
|
**--version, -v**
|
||||||
Print the version
|
Print the version
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue