0
0
mirror of https://github.com/louislam/uptime-kuma.git synced 2024-11-28 10:36:39 +01:00
uptime-kuma/extra/healthcheck.js

32 lines
662 B
JavaScript
Raw Normal View History

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
let client;
if (process.env.SSL_KEY && process.env.SSL_CERT) {
client = require("https");
} else {
client = require("http");
}
2021-08-09 07:49:37 +02:00
let options = {
host: process.env.HOST || "127.0.0.1",
port: parseInt(process.env.PORT) || 3001,
2021-09-07 11:30:50 +02:00
timeout: 120 * 1000,
};
let request = client.request(options, (res) => {
console.log(`Health Check OK [Res Code: ${res.statusCode}]`);
if (res.statusCode === 200) {
2021-08-09 07:49:37 +02:00
process.exit(0);
} else {
process.exit(1);
}
});
request.on("error", function (err) {
console.error("Health Check ERROR");
2021-08-09 07:49:37 +02:00
process.exit(1);
});
request.end();