awesome-compose/react-express-mysql/backend/healthcheck.js
Jérémie Drouet 75aa52524c react-express-mysql: split backend code
Signed-off-by: Jérémie Drouet <jeremie.drouet@gmail.com>
2020-03-23 14:18:50 +01:00

22 lines
467 B
JavaScript
Executable File

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