Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (engine): add addr grpc listen #2491

Merged
merged 1 commit into from
Mar 30, 2018
Merged
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
9 changes: 5 additions & 4 deletions engine/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ type Configuration struct {
UI string `toml:"ui" default:"http://localhost:2015"`
} `toml:"url" comment:"#####################\n CDS URLs Settings \n####################"`
HTTP struct {
Addr string `toml:"addr" default:"" commented:"true" comment:"Listen address without port, example: 127.0.0.1"`
Addr string `toml:"addr" default:"" commented:"true" comment:"Listen HTTP address without port, example: 127.0.0.1"`
Port int `toml:"port" default:"8081"`
SessionTTL int `toml:"sessionTTL" default:"60"`
} `toml:"http"`
GRPC struct {
Port int `toml:"port" default:"8082"`
Addr string `toml:"addr" default:"" commented:"true" comment:"Listen GRPC address without port, example: 127.0.0.1"`
Port int `toml:"port" default:"8082"`
} `toml:"grpc"`
Secrets struct {
Key string `toml:"key"`
Expand Down Expand Up @@ -548,12 +549,12 @@ func (a *API) Serve(ctx context.Context) error {

go func() {
//TLS is disabled for the moment. We need to serve TLS on HTTP too
if err := grpcInit(a.DBConnectionFactory, a.Config.GRPC.Port, false, "", ""); err != nil {
if err := grpcInit(a.DBConnectionFactory, a.Config.GRPC.Addr, a.Config.GRPC.Port, false, "", ""); err != nil {
log.Error("Cannot start GRPC server: %v", err)
}
}()

log.Info("Starting CDS API HTTP Server on port %d", a.Config.HTTP.Port)
log.Info("Starting CDS API HTTP Server on %s:%d", a.Config.HTTP.Addr, a.Config.HTTP.Port)
if err := s.ListenAndServe(); err != nil {
return fmt.Errorf("Cannot start HTTP server: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions engine/api/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import (
)

// grpcInit initialize all GRPC services
func grpcInit(dbConnectionFactory *database.DBConnectionFactory, port int, tls bool, certFile, keyFile string) error {
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
func grpcInit(dbConnectionFactory *database.DBConnectionFactory, addr string, port int, tls bool, certFile, keyFile string) error {
lis, err := net.Listen("tcp", fmt.Sprintf("%s:%d", addr, port))
if err != nil {
return err
}

log.Info("Starting GRPC services on port %d", port)
log.Info("Starting GRPC services on %s:%d", addr, port)

grpcHandlers := &grpcHandlers{
dbConnectionFactory: dbConnectionFactory,
Expand Down