From 37f0a669fd02fd9ee0a50337a4c08f11da5ff348 Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sat, 21 Jan 2023 16:33:11 +0000 Subject: [PATCH 1/2] Update healthcheck to 5s timeout --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index eb577661..57186aea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,4 +50,4 @@ CMD [ "yarn", "start" ] EXPOSE ${PORT} # Run simple healthchecks every 5 mins, to check that everythings still great -HEALTHCHECK --interval=5m --timeout=2s --start-period=30s CMD yarn health-check \ No newline at end of file +HEALTHCHECK --interval=5m --timeout=5s --start-period=30s CMD yarn health-check From 3c5177dd704821286d51830abe2c2840a92b7f54 Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sat, 21 Jan 2023 16:36:49 +0000 Subject: [PATCH 2/2] Update health-check to support SSL properly --- services/healthcheck.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/services/healthcheck.js b/services/healthcheck.js index 503267f3..d0b4dd82 100644 --- a/services/healthcheck.js +++ b/services/healthcheck.js @@ -4,14 +4,21 @@ * Note that exiting with code 1 indicates failure, and 0 is success */ -const http = require('http'); +const isSsl = !!process.env.SSL_PRIV_KEY_PATH && !!process.env.SSL_PUB_KEY_PATH; + +const http = require(isSsl ? 'https' : 'http'); /* Location of the server to test */ -const port = process.env.PORT || !!process.env.IS_DOCKER ? 80 : 4000; +const isDocker = !!process.env.IS_DOCKER; +const port = isSsl ? (process.env.SSL_PORT || (isDocker ? 443 : 4001)) : (process.env.PORT || isDocker ? 80 : 4000); const host = process.env.HOST || '0.0.0.0'; const timeout = 2000; -const requestOptions = { host, port, timeout }; +const agent = new http.Agent({ + rejectUnauthorized: false, // Allow self-signed certificates +}); + +const requestOptions = { host, port, timeout, agent }; const startTime = new Date(); // Initialize timestamp to calculate time taken