Add some debugging routes and envpprof to cmd/magnet-metainfo

https://github.com/anacrolix/torrent/issues/178
This commit is contained in:
Matt Joiner 2017-08-18 11:14:57 +10:00
parent 97cb41a5c9
commit 89f39b0b09
1 changed files with 8 additions and 0 deletions

View File

@ -4,9 +4,11 @@ package main
import (
"flag"
"log"
"net/http"
"os"
"sync"
_ "github.com/anacrolix/envpprof"
"github.com/anacrolix/torrent"
"github.com/anacrolix/torrent/bencode"
)
@ -17,6 +19,12 @@ func main() {
if err != nil {
log.Fatalf("error creating client: %s", err)
}
http.HandleFunc("/torrent", func(w http.ResponseWriter, r *http.Request) {
cl.WriteStatus(w)
})
http.HandleFunc("/dht", func(w http.ResponseWriter, r *http.Request) {
cl.DHT().WriteStatus(w)
})
wg := sync.WaitGroup{}
for _, arg := range flag.Args() {
t, err := cl.AddMagnet(arg)