2021-09-10 16:17:20 +03:00
|
|
|
/*
|
|
|
|
* This script should be run after a period of time (180s), because the server may need some time to prepare.
|
|
|
|
*/
|
2021-09-07 11:06:28 +03:00
|
|
|
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 08:49:37 +03:00
|
|
|
let options = {
|
2021-09-07 11:06:28 +03:00
|
|
|
host: process.env.HOST || "127.0.0.1",
|
|
|
|
port: parseInt(process.env.PORT) || 3001,
|
2021-09-09 06:41:28 +03:00
|
|
|
timeout: 28 * 1000,
|
2021-07-17 17:37:35 +03:00
|
|
|
};
|
2021-09-07 11:06:28 +03:00
|
|
|
|
|
|
|
let request = client.request(options, (res) => {
|
|
|
|
console.log(`Health Check OK [Res Code: ${res.statusCode}]`);
|
|
|
|
if (res.statusCode === 200) {
|
2021-08-09 08:49:37 +03:00
|
|
|
process.exit(0);
|
|
|
|
} else {
|
|
|
|
process.exit(1);
|
|
|
|
}
|
2021-07-17 17:37:35 +03:00
|
|
|
});
|
2021-09-07 11:06:28 +03:00
|
|
|
|
2021-07-17 17:37:35 +03:00
|
|
|
request.on("error", function (err) {
|
2021-09-07 11:06:28 +03:00
|
|
|
console.error("Health Check ERROR");
|
2021-08-09 08:49:37 +03:00
|
|
|
process.exit(1);
|
2021-07-17 17:37:35 +03:00
|
|
|
});
|
2021-09-07 11:06:28 +03:00
|
|
|
|
2021-07-17 17:37:35 +03:00
|
|
|
request.end();
|