Prototype of grpc API

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov
2015-12-09 14:18:31 -08:00
parent e87f8336c4
commit e14e4576c9
6 changed files with 1331 additions and 0 deletions

View File

@@ -2,15 +2,21 @@ package main
import (
"log"
"net"
"net/http"
"os"
"runtime"
"sync"
"time"
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
"github.com/docker/containerd"
"github.com/docker/containerd/api/grpc/server"
"github.com/docker/containerd/api/grpc/types"
"github.com/docker/containerd/api/v1"
"github.com/rcrowley/go-metrics"
)
@@ -115,6 +121,16 @@ func daemon(id, stateDir string, concurrency, bufferSize int) error {
if err := supervisor.Start(); err != nil {
return err
}
if os.Getenv("GRPC") != "" {
lis, err := net.Listen("tcp", ":8888")
if err != nil {
grpclog.Fatalf("failed to listen: %v", err)
}
grpcServer := grpc.NewServer()
types.RegisterAPIServer(grpcServer, server.NewServer(supervisor))
return grpcServer.Serve(lis)
}
server := v1.NewServer(supervisor)
return http.ListenAndServe("localhost:8888", server)
}