summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-06-03 19:07:24 +0200
committerStefan Haller <stefan@haller-berlin.de>2024-06-03 19:07:24 +0200
commitab0b0da850f7a1caaf16d7e49460c7868cc90d92 (patch)
treefc2b036d67c9bd642cda03739a12362c4d146822
parentb85687797d7ab4b197b876d47be25d6b2e0704d4 (diff)
Add -profile command line flag
When on, start a built-in web server that takes requests on port 6060 to gather profiling data.
-rw-r--r--pkg/app/entry_point.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/app/entry_point.go b/pkg/app/entry_point.go
index baeb43ae5..96f6176c7 100644
--- a/pkg/app/entry_point.go
+++ b/pkg/app/entry_point.go
@@ -4,6 +4,8 @@ import (
"bytes"
"fmt"
"log"
+ "net/http"
+ _ "net/http/pprof"
"os"
"os/exec"
"path/filepath"
@@ -30,6 +32,7 @@ type cliArgs struct {
PrintVersionInfo bool
Debug bool
TailLogs bool
+ Profile bool
PrintDefaultConfig bool
PrintConfigDir bool
UseConfigDir string
@@ -145,6 +148,14 @@ func Start(buildInfo *BuildInfo, integrationTest integrationTypes.IntegrationTes
return
}
+ if cliArgs.Profile {
+ go func() {
+ if err := http.ListenAndServe("localhost:6060", nil); err != nil {
+ log.Fatal(err)
+ }
+ }()
+ }
+
parsedGitArg := parseGitArg(cliArgs.GitArg)
Run(appConfig, common, appTypes.NewStartArgs(cliArgs.FilterPath, parsedGitArg, integrationTest))
@@ -171,6 +182,9 @@ func parseCliArgsAndEnvVars() *cliArgs {
tailLogs := false
flaggy.Bool(&tailLogs, "l", "logs", "Tail lazygit logs (intended to be used when `lazygit --debug` is called in a separate terminal tab)")
+ profile := false
+ flaggy.Bool(&profile, "", "profile", "Start the profiler and serve it on http port 6060. See CONTRIBUTING.md for more info.")
+
printDefaultConfig := false
flaggy.Bool(&printDefaultConfig, "c", "config", "Print the default config")
@@ -202,6 +216,7 @@ func parseCliArgsAndEnvVars() *cliArgs {
PrintVersionInfo: printVersionInfo,
Debug: debug,
TailLogs: tailLogs,
+ Profile: profile,
PrintDefaultConfig: printDefaultConfig,
PrintConfigDir: printConfigDir,
UseConfigDir: useConfigDir,