mirror of
https://github.com/LBRYFoundation/reflector.go.git
synced 2025-08-23 17:27:25 +00:00
test reflector server
This commit is contained in:
parent
e03810903a
commit
030ed4914d
1 changed files with 36 additions and 1 deletions
37
cmd/test.go
37
cmd/test.go
|
@ -1,6 +1,18 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
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"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -15,5 +27,28 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCmd(cmd *cobra.Command, args []string) {
|
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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue