From e0f2f5ec4ab29a00cda028fdb5b34d421076e168 Mon Sep 17 00:00:00 2001 From: Abhilash Gnan Date: Sat, 4 May 2019 14:32:13 +0200 Subject: [PATCH] fix product catalog servicde ports --- kubernetes-manifests/productcatalogservice.yaml | 3 +++ src/productcatalogservice/server.go | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/kubernetes-manifests/productcatalogservice.yaml b/kubernetes-manifests/productcatalogservice.yaml index 9161a54..34a5628 100644 --- a/kubernetes-manifests/productcatalogservice.yaml +++ b/kubernetes-manifests/productcatalogservice.yaml @@ -31,6 +31,9 @@ spec: image: productcatalogservice ports: - containerPort: 3550 + env: + - name: PORT + value: "3550" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:3550"] diff --git a/src/productcatalogservice/server.go b/src/productcatalogservice/server.go index c55e0af..60b0f3a 100644 --- a/src/productcatalogservice/server.go +++ b/src/productcatalogservice/server.go @@ -50,7 +50,7 @@ var ( log *logrus.Logger extraLatency time.Duration - port = flag.Int("port", 3550, "port to listen at") + port = "3550" reloadCatalog bool ) @@ -106,13 +106,16 @@ func main() { } }() - log.Infof("starting grpc server at :%d", *port) - run(*port) + if os.Getenv("PORT") != "" { + port = os.Getenv("PORT") + } + log.Infof("starting grpc server at :%s", port) + run(port) select {} } -func run(port int) string { - l, err := net.Listen("tcp", fmt.Sprintf(":%d", port)) +func run(port string) string { + l, err := net.Listen("tcp", fmt.Sprintf(":%s", port)) if err != nil { log.Fatal(err) }