-
-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathhealthcheck.js
More file actions
27 lines (24 loc) · 628 Bytes
/
healthcheck.js
File metadata and controls
27 lines (24 loc) · 628 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require("dotenv").config();
const http = require("http");
const config = require("./build/config");
const options = {
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 || 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", err);
process.exit(1);
});
request.end();