Skip to content

Commit

Permalink
add pprof
Browse files Browse the repository at this point in the history
  • Loading branch information
huangnauh committed Jul 17, 2024
1 parent 1575b59 commit f8dc41a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ func NewGetCommand() cli.Command {
PrintErrorAndExit("get %s: parse mtime: %v", upPath, err)
}
}
if c.Int("w") > 10 || c.Int("w") < 1 {
PrintErrorAndExit("max concurrent threads must between (1 - 10)")
if c.Int("w") > 50 || c.Int("w") < 1 {
PrintErrorAndExit("max concurrent threads must between (1 - 50)")
}
if mc.Start != "" || mc.End != "" {
session.GetStartBetweenEndFiles(upPath, localPath, mc, c.Int("w"))
Expand Down
4 changes: 2 additions & 2 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (sess *Session) FormatUpInfo(upInfo *upyun.FileInfo) string {

func (sess *Session) Init() error {
sess.scores = make(map[int]int)
PrintOnlyVerbose("hosts %v\n", sess.Hosts)
// PrintOnlyVerbose("hosts %v\n", sess.Hosts)
sess.updriver = upyun.NewUpYun(&upyun.UpYunConfig{
Bucket: sess.Bucket,
Operator: sess.Operator,
Expand Down Expand Up @@ -336,7 +336,7 @@ func (sess *Session) getDir(upPath, localPath string, match *MatchConfig, worker
}
}
if e != nil {
return
continue
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions upx.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (
"runtime"
"time"

"net/http"
_ "net/http/pprof"

"github.com/urfave/cli"
)

Expand All @@ -23,6 +26,7 @@ func CreateUpxApp() *cli.App {
app.Flags = []cli.Flag{
cli.BoolFlag{Name: "quiet, q", Usage: "not verbose"},
cli.StringFlag{Name: "auth", Usage: "auth string"},
cli.StringFlag{Name: "pprof-addr", Usage: "enable pprof"},
}
app.Before = func(c *cli.Context) error {
if c.Bool("q") {
Expand All @@ -34,6 +38,11 @@ func CreateUpxApp() *cli.App {
PrintErrorAndExit("%s: invalid auth string", c.Command.FullName())
}
}
if c.String("pprof-addr") != "" {
go func() {
http.ListenAndServe(c.String("pprof-addr"), nil)
}()
}
return nil
}
app.Commands = []cli.Command{
Expand Down

0 comments on commit f8dc41a

Please sign in to comment.