Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions code/go/0chain.net/blobber/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ require (
github.com/gorilla/mux v1.7.3
github.com/spf13/viper v1.7.0
go.uber.org/zap v1.15.0
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f // indirect
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa // indirect
google.golang.org/grpc v1.33.1
)

go 1.13
41 changes: 41 additions & 0 deletions code/go/0chain.net/blobber/go.sum

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions code/go/0chain.net/blobber/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"log"
"net"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -232,6 +233,7 @@ func main() {
metadataDB = flag.String("db_dir", "", "db_dir")
logDir := flag.String("log_dir", "", "log_dir")
portString := flag.String("port", "", "port")
grpcPortString := flag.String("grpc_port", "", "grpc_port")
hostname := flag.String("hostname", "", "hostname")

flag.Parse()
Expand Down Expand Up @@ -266,6 +268,10 @@ func main() {
panic("Please specify --port which is the port on which requests are accepted")
}

if *grpcPortString == "" {
panic("Please specify --grpc_port which is the grpc port on which requests are accepted")
}

reader, err := os.Open(*keysFile)
if err != nil {
panic(err)
Expand Down Expand Up @@ -346,6 +352,9 @@ func main() {
initHandlers(r)
initServer()

grpcServer := handler.NewServerWithMiddlewares()
handler.RegisterGRPCServices(r, grpcServer)

rHandler := handlers.CORS(originsOk, headersOk, methodsOk)(r)
if config.Development() {
// No WriteTimeout setup to enable pprof
Expand All @@ -370,6 +379,13 @@ func main() {

Logger.Info("Ready to listen to the requests")
startTime = time.Now().UTC()
go func(grpcPort string) {
lis, err := net.Listen("tcp", fmt.Sprintf(":%s", grpcPort))
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
log.Fatal(grpcServer.Serve(lis))
}(*grpcPortString)
log.Fatal(server.ListenAndServe())
}

Expand Down
Loading