summaryrefslogtreecommitdiff
path: root/cmd/kpod
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/kpod')
-rw-r--r--cmd/kpod/main.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/cmd/kpod/main.go b/cmd/kpod/main.go
index ab95995fe..97d942a3c 100644
--- a/cmd/kpod/main.go
+++ b/cmd/kpod/main.go
@@ -3,8 +3,10 @@ package main
import (
"fmt"
"os"
+ "runtime/pprof"
"github.com/containers/storage/pkg/reexec"
+ "github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
@@ -15,6 +17,7 @@ var kpodVersion = ""
func main() {
debug := false
+ cpuProfile := false
if reexec.Init() {
return
@@ -77,12 +80,23 @@ func main() {
debug = true
}
-
+ if c.GlobalIsSet("cpu-profile") {
+ f, err := os.Create(c.GlobalString("cpu-profile"))
+ if err != nil {
+ return errors.Wrapf(err, "unable to create cpu profiling file %s",
+ c.GlobalString("cpu-profile"))
+ }
+ cpuProfile = true
+ pprof.StartCPUProfile(f)
+ }
return nil
}
app.After = func(*cli.Context) error {
// called by Run() when the command handler succeeds
shutdownStores()
+ if cpuProfile {
+ pprof.StopCPUProfile()
+ }
return nil
}
cli.OsExiter = func(code int) {
@@ -100,6 +114,10 @@ func main() {
Usage: "path of the conmon binary",
},
cli.StringFlag{
+ Name: "cpu-profile",
+ Usage: "path for the cpu profiling results",
+ },
+ cli.StringFlag{
Name: "log-level",
Usage: "log messages above specified level: debug, info, warn, error (default), fatal or panic",
Value: "error",