From: Matt Joiner Date: Fri, 1 Sep 2017 00:35:40 +0000 (+1000) Subject: cmd/torrent: Enhance debugging X-Git-Tag: v1.0.0~417 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=016b238cc528ac5166bcdf66196de4657af2c4f6;p=btrtrc.git cmd/torrent: Enhance debugging --- diff --git a/cmd/torrent/main.go b/cmd/torrent/main.go index bf21b22b..bb614264 100644 --- a/cmd/torrent/main.go +++ b/cmd/torrent/main.go @@ -2,6 +2,7 @@ package main import ( + "expvar" "fmt" "log" "net" @@ -11,7 +12,7 @@ import ( "time" "github.com/anacrolix/dht" - _ "github.com/anacrolix/envpprof" + "github.com/anacrolix/envpprof" "github.com/anacrolix/tagflag" "github.com/dustin/go-humanize" "github.com/gosuri/uiprogress" @@ -139,6 +140,7 @@ var flags = struct { Addr *net.TCPAddr `help:"network listen addr"` UploadRate tagflag.Bytes `help:"max piece bytes to send per second"` DownloadRate tagflag.Bytes `help:"max bytes per second down from peers"` + Debug bool tagflag.StartPos Torrent []string `arity:"+" help:"torrent file path or magnet uri"` }{ @@ -191,4 +193,8 @@ func main() { if flags.Seed { select {} } + expvar.Do(func(kv expvar.KeyValue) { + fmt.Printf("%s: %s\n", kv.Key, kv.Value) + }) + envpprof.Stop() }