From c203317b3b74002ffa37f9b76f5ff8fc04a8a58a Mon Sep 17 00:00:00 2001 From: Niyas Date: Sat, 17 Jul 2021 20:07:35 +0530 Subject: [PATCH] Docker healthcheck Copied from https://scoutapm.com/blog/how-to-use-docker-healthcheck --- extra/healthcheck.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 extra/healthcheck.js diff --git a/extra/healthcheck.js b/extra/healthcheck.js new file mode 100644 index 000000000..b547fbcba --- /dev/null +++ b/extra/healthcheck.js @@ -0,0 +1,19 @@ +var http = require("http"); +var options = { + host: "localhost", + port: "3001", + timeout: 2000, +}; +var request = http.request(options, (res) => { + console.log(`STATUS: ${res.statusCode}`); + if (res.statusCode == 200) { + process.exit(0); + } else { + process.exit(1); + } +}); +request.on("error", function (err) { + console.log("ERROR"); + process.exit(1); +}); +request.end();