ricochet-go/backend/backend.go

38 lines
717 B
Go
Raw Normal View History

2016-08-02 02:58:10 +00:00
package main
import (
2016-10-17 04:26:35 +00:00
ricochet "github.com/ricochet-im/ricochet-go/core"
rpc "github.com/ricochet-im/ricochet-go/rpc"
2016-08-02 02:58:10 +00:00
"google.golang.org/grpc"
"log"
"net"
)
const (
defaultListener = "127.0.0.1:58281"
)
func main() {
listener, err := net.Listen("tcp", defaultListener)
if err != nil {
log.Fatalf("listen failed: %v", err)
}
2016-08-02 23:28:26 +00:00
config, err := ricochet.LoadConfig(".")
if err != nil {
log.Fatalf("config error: %v", err)
}
2016-09-11 04:57:54 +00:00
core := new(ricochet.Ricochet)
if err := core.Init(config); err != nil {
log.Fatalf("init error: %v", err)
2016-08-02 23:28:26 +00:00
}
2016-11-04 04:37:00 +00:00
server := &ricochet.RpcServer{
Core: core,
2016-09-11 04:57:54 +00:00
}
grpcServer := grpc.NewServer()
rpc.RegisterRicochetCoreServer(grpcServer, server)
grpcServer.Serve(listener)
2016-08-02 02:58:10 +00:00
}