mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-08 23:56:15 +02:00
Add -profile command line flag
When on, start a built-in web server that takes requests on port 6060 to gather profiling data.
This commit is contained in:
parent
b85687797d
commit
ab0b0da850
@ -4,6 +4,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -30,6 +32,7 @@ type cliArgs struct {
|
|||||||
PrintVersionInfo bool
|
PrintVersionInfo bool
|
||||||
Debug bool
|
Debug bool
|
||||||
TailLogs bool
|
TailLogs bool
|
||||||
|
Profile bool
|
||||||
PrintDefaultConfig bool
|
PrintDefaultConfig bool
|
||||||
PrintConfigDir bool
|
PrintConfigDir bool
|
||||||
UseConfigDir string
|
UseConfigDir string
|
||||||
@ -145,6 +148,14 @@ func Start(buildInfo *BuildInfo, integrationTest integrationTypes.IntegrationTes
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cliArgs.Profile {
|
||||||
|
go func() {
|
||||||
|
if err := http.ListenAndServe("localhost:6060", nil); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
parsedGitArg := parseGitArg(cliArgs.GitArg)
|
parsedGitArg := parseGitArg(cliArgs.GitArg)
|
||||||
|
|
||||||
Run(appConfig, common, appTypes.NewStartArgs(cliArgs.FilterPath, parsedGitArg, integrationTest))
|
Run(appConfig, common, appTypes.NewStartArgs(cliArgs.FilterPath, parsedGitArg, integrationTest))
|
||||||
@ -171,6 +182,9 @@ func parseCliArgsAndEnvVars() *cliArgs {
|
|||||||
tailLogs := false
|
tailLogs := false
|
||||||
flaggy.Bool(&tailLogs, "l", "logs", "Tail lazygit logs (intended to be used when `lazygit --debug` is called in a separate terminal tab)")
|
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
|
printDefaultConfig := false
|
||||||
flaggy.Bool(&printDefaultConfig, "c", "config", "Print the default config")
|
flaggy.Bool(&printDefaultConfig, "c", "config", "Print the default config")
|
||||||
|
|
||||||
@ -202,6 +216,7 @@ func parseCliArgsAndEnvVars() *cliArgs {
|
|||||||
PrintVersionInfo: printVersionInfo,
|
PrintVersionInfo: printVersionInfo,
|
||||||
Debug: debug,
|
Debug: debug,
|
||||||
TailLogs: tailLogs,
|
TailLogs: tailLogs,
|
||||||
|
Profile: profile,
|
||||||
PrintDefaultConfig: printDefaultConfig,
|
PrintDefaultConfig: printDefaultConfig,
|
||||||
PrintConfigDir: printConfigDir,
|
PrintConfigDir: printConfigDir,
|
||||||
UseConfigDir: useConfigDir,
|
UseConfigDir: useConfigDir,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user