2020-03-23 13:18:50 +00:00
|
|
|
const http = require("http");
|
2020-03-05 17:40:44 +00:00
|
|
|
|
2020-03-23 13:18:50 +00:00
|
|
|
const options = {
|
2020-03-05 17:40:44 +00:00
|
|
|
timeout: 2000,
|
2020-03-23 13:18:50 +00:00
|
|
|
host: "localhost",
|
2020-03-05 17:40:44 +00:00
|
|
|
port: process.env.PORT || 8080,
|
2020-03-23 13:18:50 +00:00
|
|
|
path: "/healthz" // must be the same as HEALTHCHECK in Dockerfile
|
2020-03-05 17:40:44 +00:00
|
|
|
};
|
|
|
|
|
2020-03-23 13:18:50 +00:00
|
|
|
const request = http.request(options, res => {
|
|
|
|
console.info("STATUS: " + res.statusCode);
|
|
|
|
process.exitCode = res.statusCode === 200 ? 0 : 1;
|
2020-03-05 17:40:44 +00:00
|
|
|
process.exit();
|
|
|
|
});
|
|
|
|
|
2020-03-23 13:18:50 +00:00
|
|
|
request.on("error", function(err) {
|
|
|
|
console.error("ERROR", err);
|
2020-03-05 17:40:44 +00:00
|
|
|
process.exit(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
request.end();
|