mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-09-23 10:50:43 +02:00
fix: fix healthcheck
This commit is contained in:
+10
-6
@@ -1,22 +1,26 @@
|
||||
require("dotenv").config();
|
||||
const http = require("http");
|
||||
const config = require("./config");
|
||||
const config = require("./build/config");
|
||||
|
||||
const options = {
|
||||
host: "localhost",
|
||||
port: config.PORT,
|
||||
path: "/healthcheck",
|
||||
method: "GET",
|
||||
host: "127.0.0.1",
|
||||
port: config.default.PORT,
|
||||
timeout: 2000,
|
||||
};
|
||||
|
||||
const request = http.request(options, (res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.statusCode == 200 || res.statusCode == 404) {
|
||||
process.exit(0);
|
||||
} else {
|
||||
const reqURL = `${res.req.protocol}://${res.req.host}:${options.port}${res.req.path}`;
|
||||
console.log(reqURL, res.statusCode);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
request.on("error", (err) => {
|
||||
console.log("ERROR");
|
||||
console.log("ERROR", err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user