提交 debd3000 编写于 作者: J jiazhiguang

fix epm listen address and configuration file

上级 b29509be
文件已添加
...@@ -6,6 +6,8 @@ import ( ...@@ -6,6 +6,8 @@ import (
"net" "net"
"time" "time"
"github.com/golang/glog"
"github.com/alibaba/inclavare-containers/epm/cmd/epm/app/options" "github.com/alibaba/inclavare-containers/epm/cmd/epm/app/options"
"github.com/alibaba/inclavare-containers/epm/config" "github.com/alibaba/inclavare-containers/epm/config"
"github.com/alibaba/inclavare-containers/epm/pkg/epm" "github.com/alibaba/inclavare-containers/epm/pkg/epm"
...@@ -16,7 +18,7 @@ import ( ...@@ -16,7 +18,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
) )
func runServer(opts *options.Options) error { func runServer(opts *options.Options, stopCh <-chan struct{}) error {
var err error var err error
var cfg config.Config var cfg config.Config
...@@ -36,11 +38,11 @@ func runServer(opts *options.Options) error { ...@@ -36,11 +38,11 @@ func runServer(opts *options.Options) error {
serverOpts = append(serverOpts, grpc.MaxSendMsgSize(cfg.GRPC.MaxSendMsgSize)) serverOpts = append(serverOpts, grpc.MaxSendMsgSize(cfg.GRPC.MaxSendMsgSize))
} }
metadata, err := cache_metadata.NewMetadataServer(cfg.DBPath, time.Second*time.Duration(cfg.DBTimeout)) metadata, err := cache_metadata.NewMetadataServer(cfg.DBPath, time.Second*time.Duration(cfg.DBTimeout))
defer metadata.Close()
if err != nil { if err != nil {
return fmt.Errorf("create metadata server failed. %++v", err) return fmt.Errorf("create metadata server failed. %++v", err)
} }
defer metadata.Close()
server := epm.EnclavePoolManagerServer{} server := epm.EnclavePoolManagerServer{}
...@@ -58,12 +60,14 @@ func runServer(opts *options.Options) error { ...@@ -58,12 +60,14 @@ func runServer(opts *options.Options) error {
// registry and start the cache pool manager server // registry and start the cache pool manager server
v1alpha1.RegisterEnclavePoolManagerServer(s, &server) v1alpha1.RegisterEnclavePoolManagerServer(s, &server)
// listen and serve // listen and serve
lis, err := net.Listen("udp", cfg.GRPC.Address) lis, err := net.Listen("unix", cfg.GRPC.Address)
if err != nil { if err != nil {
log.Fatalf("failed to listen: %v", err) log.Fatalf("failed to listen: %v", err)
} }
glog.Info("start the and epm server...")
if err := s.Serve(lis); err != nil { if err := s.Serve(lis); err != nil {
log.Fatalf("failed to start cache pool manager server: %v", err) log.Fatalf("failed to start epm server: %v", err)
} }
<-stopCh
return nil return nil
} }
...@@ -6,13 +6,13 @@ import ( ...@@ -6,13 +6,13 @@ import (
) )
// NewEnclavePoolManagerServer creat and start the enclave pool manager server // NewEnclavePoolManagerServer creat and start the enclave pool manager server
func NewEnclavePoolManagerServer() *cobra.Command { func NewEnclavePoolManagerServer(stopCh <-chan struct{}) *cobra.Command {
opts := &options.Options{} opts := &options.Options{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Short: "Launch signature server", Short: "Launch signature server",
Long: "Launch signature server", Long: "Launch signature server",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return runServer(opts) return runServer(opts, stopCh)
}, },
} }
flags := cmd.Flags() flags := cmd.Flags()
......
...@@ -3,24 +3,42 @@ package main ...@@ -3,24 +3,42 @@ package main
import ( import (
"flag" "flag"
"os" "os"
"os/signal"
"runtime" "runtime"
"syscall"
"github.com/alibaba/inclavare-containers/epm/cmd/epm/app" "github.com/alibaba/inclavare-containers/epm/cmd/epm/app"
"github.com/golang/glog" "github.com/golang/glog"
) )
var onlyOneSignalHandler = make(chan struct{})
var shutdownSignals = []os.Signal{os.Interrupt, syscall.SIGTERM}
func setupSignalHandler() <-chan struct{} {
close(onlyOneSignalHandler) // panics when called twice
stop := make(chan struct{})
c := make(chan os.Signal, 2)
signal.Notify(c, shutdownSignals...)
go func() {
<-c
close(stop)
<-c
os.Exit(1) // second signal. Exit directly.
}()
return stop
}
func main() { func main() {
if len(os.Getenv("GOMAXPROCS")) == 0 { if len(os.Getenv("GOMAXPROCS")) == 0 {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())
} }
stopCh := setupSignalHandler()
cmd := app.NewEnclavePoolManagerServer() cmd := app.NewEnclavePoolManagerServer(stopCh)
cmd.Flags().AddGoFlagSet(flag.CommandLine) cmd.Flags().AddGoFlagSet(flag.CommandLine)
if err := cmd.Execute(); err != nil {
glog.Fatal(err)
}
flag.CommandLine.Parse([]string{}) flag.CommandLine.Parse([]string{})
if err := cmd.Execute(); err != nil { if err := cmd.Execute(); err != nil {
glog.Fatal(err) glog.Fatal(err)
......
...@@ -3,7 +3,7 @@ db_path = "/var/local/epm/epm.db" ...@@ -3,7 +3,7 @@ db_path = "/var/local/epm/epm.db"
db_timeout = 10 db_timeout = 10
[grpc] [grpc]
address = "/var/run/containerd/containerd.sock" address = "/var/run/epm.sock"
uid = 0 uid = 0
gid = 0 gid = 0
max_recv_message_size = 16777216 max_recv_message_size = 16777216
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册