Skip to content

Commit

Permalink
Add -gops option to init gops agent
Browse files Browse the repository at this point in the history
  • Loading branch information
disq committed Jan 12, 2017
1 parent 7a1e9f5 commit 602db8e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Usage: ./s5cmd [OPTION]... [COMMAND [PARAMS...]]
Multipart chunk size in MB for uploads (default 5, auto calculated)
-f string
Commands-file or - for stdin
-gops
Initialize gops agent
-numworkers int
Number of worker goroutines. Negative numbers mean multiples of runtime.NumCPU (default 256)
-r int
Expand Down
10 changes: 8 additions & 2 deletions s5cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"time"

"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/google/gops/agent"
"github.com/peakgames/s5cmd/core"
"github.com/peakgames/s5cmd/stats"
"github.com/peakgames/s5cmd/version"
Expand Down Expand Up @@ -63,6 +64,7 @@ func main() {
flag.IntVar(&retries, "r", 10, "Retry S3 operations N times before failing")
printStats := flag.Bool("stats", false, "Always print stats")
version := flag.Bool("version", false, "Prints current version")
gops := flag.Bool("gops", false, "Initialize gops agent")

flag.Usage = func() {
printUsageLine()
Expand All @@ -71,6 +73,12 @@ func main() {
}
flag.Parse()

if *gops {
if err := agent.Listen(&agent.Options{NoShutdownCleanup: true}); err != nil {
log.Fatal("-ERR", err)
}
}

if *version {
fmt.Printf("s5cmd version %s", GitSummary)
if GitBranch != "" {
Expand All @@ -91,11 +99,9 @@ func main() {
cmd := strings.Join(flag.Args(), " ")
if cmd != "" && cmdFile != "" {
log.Fatal("-ERR Only specify -f or command, not both")
os.Exit(1)
}
if (cmd == "" && cmdFile == "") || numWorkers == 0 || multipartChunkSize < 1 || retries < 0 {
log.Fatal("-ERR Please specify all arguments.")
os.Exit(1)
}

multipartChunkSizeBytes := int64(multipartChunkSize * int(bytesInMb))
Expand Down

0 comments on commit 602db8e

Please sign in to comment.