Merge pull request #16 from LK4D4/grpc_api

Prototype of grpc API
This commit is contained in:
Michael Crosby
2015-12-09 15:08:40 -08:00
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/docker/containerd/util"
"github.com/rcrowley/go-metrics"
@@ -144,6 +150,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)
}