From c12370dd1097abe95c8e0ffa54c0d6a0c937879a Mon Sep 17 00:00:00 2001 From: Clemens Wolff Date: Thu, 26 Dec 2019 00:04:41 -0500 Subject: [PATCH] Expose healthcheck endpoint (#269) * Expose healthcheck endpoint * Wait for service to be live before running tests --- docker/integtest/0-wait-for-services.sh | 10 ++++++++++ docker/nginx/nginx.conf.template | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/docker/integtest/0-wait-for-services.sh b/docker/integtest/0-wait-for-services.sh index e3ef856d..f3159ce8 100755 --- a/docker/integtest/0-wait-for-services.sh +++ b/docker/integtest/0-wait-for-services.sh @@ -41,6 +41,16 @@ wait_for_appinsights() { log "Appinsights is running" } +wait_for_api() { + while ! curl -fs "http://nginx:8888/healthcheck/ping" >/dev/null; do + log "Waiting for api" + sleep "${polling_interval_seconds}s" + done + + log "Api is running" +} + wait_for_rabbitmq wait_for_postgres wait_for_appinsights +wait_for_api diff --git a/docker/nginx/nginx.conf.template b/docker/nginx/nginx.conf.template index 607a94d7..2c26d92d 100644 --- a/docker/nginx/nginx.conf.template +++ b/docker/nginx/nginx.conf.template @@ -22,6 +22,14 @@ http { keepalive_timeout 65; + upstream healthcheck_hosts { + server ${HOSTNAME_EMAIL_RECEIVE}; + server ${HOSTNAME_CLIENT_METRICS}; + server ${HOSTNAME_CLIENT_WRITE}; + server ${HOSTNAME_CLIENT_READ}; + server ${HOSTNAME_CLIENT_REGISTER}; + } + server { listen ${PORT}; @@ -37,6 +45,10 @@ http { root /static; } + location /healthcheck { + proxy_pass http://healthcheck_hosts; + } + location /api/email/sendgrid { proxy_pass http://${HOSTNAME_EMAIL_RECEIVE}; }