reflector.go/cmd/peer.go

32 lines
739 B
Go
Raw Normal View History

2018-02-02 22:48:57 +01:00
package cmd
import (
"strconv"
"github.com/lbryio/reflector.go/db"
"github.com/lbryio/reflector.go/peer"
"github.com/lbryio/reflector.go/store"
log "github.com/sirupsen/logrus"
2018-02-02 22:48:57 +01:00
"github.com/spf13/cobra"
)
func init() {
var cmd = &cobra.Command{
2018-02-02 22:48:57 +01:00
Use: "peer",
Short: "Run peer server",
Run: peerCmd,
}
RootCmd.AddCommand(cmd)
2018-02-02 22:48:57 +01:00
}
func peerCmd(cmd *cobra.Command, args []string) {
db := new(db.SQL)
err := db.Connect(GlobalConfig.DBConn)
checkErr(err)
s3 := store.NewS3BlobStore(GlobalConfig.AwsID, GlobalConfig.AwsSecret, GlobalConfig.BucketRegion, GlobalConfig.BucketName)
combo := store.NewDBBackedS3Store(s3, db)
log.Fatal(peer.NewServer(combo).ListenAndServe("localhost:" + strconv.Itoa(peer.DefaultPort)))
}