test reflector server

This commit is contained in:
Alex Grintsvayg 2019-01-29 14:28:40 -05:00
parent e03810903a
commit 030ed4914d
No known key found for this signature in database
GPG key ID: AEB3F089F86A22B5

View file

@ -1,6 +1,18 @@
package cmd
import (
"os"
"os/signal"
"strconv"
"syscall"
"time"
"github.com/lbryio/reflector.go/meta"
"github.com/lbryio/reflector.go/peer"
"github.com/lbryio/reflector.go/reflector"
"github.com/lbryio/reflector.go/store"
"github.com/davecgh/go-spew/spew"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@ -15,5 +27,28 @@ func init() {
}
func testCmd(cmd *cobra.Command, args []string) {
log.Println("test :-)")
log.Printf("reflector version %s", meta.Version)
memStore := &store.MemoryBlobStore{}
reflectorServer := reflector.NewServer(memStore)
reflectorServer.Timeout = 3 * time.Minute
err := reflectorServer.Start(":" + strconv.Itoa(reflector.DefaultPort))
if err != nil {
log.Fatal(err)
}
peerServer := peer.NewServer(memStore)
err = peerServer.Start(":5567")
if err != nil {
log.Fatal(err)
}
interruptChan := make(chan os.Signal, 1)
signal.Notify(interruptChan, os.Interrupt, syscall.SIGTERM)
<-interruptChan
peerServer.Shutdown()
reflectorServer.Shutdown()
spew.Dump(memStore)
}