From ab2b15723c9f8d843b8d73b9f65ba3df904619f6 Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Mon, 16 Jul 2018 10:21:41 -0700 Subject: [PATCH] frontend: use LISTEN_ADDR, refactor Listen code Signed-off-by: Ahmet Alp Balkan --- kubernetes-manifests/frontend.yaml | 2 ++ src/frontend/main.go | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/kubernetes-manifests/frontend.yaml b/kubernetes-manifests/frontend.yaml index 3c536f9..0a11ff2 100644 --- a/kubernetes-manifests/frontend.yaml +++ b/kubernetes-manifests/frontend.yaml @@ -42,6 +42,8 @@ spec: value: "shippingservice:50051" - name: CHECKOUT_SERVICE_ADDR value: "checkoutservice:5050" + - name: LISTEN_ADDR + value: "0.0.0.0" resources: requests: cpu: 100m diff --git a/src/frontend/main.go b/src/frontend/main.go index a266139..a270699 100644 --- a/src/frontend/main.go +++ b/src/frontend/main.go @@ -107,9 +107,17 @@ func main() { Handler: handler, Propagation: &b3.HTTPFormat{}} - log.Infof("starting server on " + addr + ":" + srvPort) - go log.Fatal(http.ListenAndServe(addr+":"+secondaryPort, handler)) - log.Fatal(http.ListenAndServe(addr+":"+srvPort, handler)) + go func() { + log.Infof("starting server on " + addr + ":" + srvPort) + log.Fatal(http.ListenAndServe(addr+":"+srvPort, handler)) + }() + + go func() { + log.Infof("starting healthcheck server on " + addr + ":" + secondaryPort) + log.Fatal(http.ListenAndServe(addr+":"+secondaryPort, handler)) + }() + + select {} } func initTracing(log logrus.FieldLogger) {