1
0
mirror of https://github.com/gilbertchen/duplicacy synced 2025-12-06 00:03:38 +00:00

Add the global -profile option to enable profiling

This commit is contained in:
Gilbert Chen
2017-12-14 15:34:05 -05:00
parent dfbc5ece00
commit 9fdff7b150

View File

@@ -16,6 +16,9 @@ import (
"runtime"
"strconv"
"strings"
"net/http"
_ "net/http/pprof"
"github.com/gilbertchen/cli"
@@ -138,6 +141,15 @@ func setGlobalOptions(context *cli.Context) {
ScriptEnabled = false
}
address := context.GlobalString("profile")
if address != "" {
go func() {
http.ListenAndServe(address, nil)
}()
}
duplicacy.RunInBackground = context.GlobalBool("background")
}
@@ -1302,7 +1314,7 @@ func main() {
},
cli.BoolFlag{
Name: "dry-run",
Usage: "Dry run for testing, don't backup anything. Use with -stats and -d",
Usage: "dry run for testing, don't backup anything. Use with -stats and -d",
},
cli.BoolFlag{
Name: "vss",
@@ -1811,7 +1823,13 @@ func main() {
Name: "background",
Usage: "read passwords, tokens, or keys only from keychain/keyring or env",
},
}
cli.StringFlag{
Name: "profile",
Value: "",
Usage: "enable the profiling tool and listen on the specified address:port",
Argument: "<address:port>",
},
}
app.HideVersion = true
app.Name = "duplicacy"