Adding Health Check for cloud providers
This commit is contained in:
parent
05eb9f5391
commit
77ddc718c5
@ -4,12 +4,23 @@ import "reflect-metadata";
|
|||||||
import { Container } from "typedi";
|
import { Container } from "typedi";
|
||||||
import { BackendVariables } from "@Common/config/variables/Variables";
|
import { BackendVariables } from "@Common/config/variables/Variables";
|
||||||
import CronService from "@Services/common/CronService/CronService";
|
import CronService from "@Services/common/CronService/CronService";
|
||||||
|
import http from "http";
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
console.info("Cron started");
|
console.info("Cron started");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const variables = await Container.get(BackendVariables).validate();
|
const variables = await Container.get(BackendVariables).validate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cloud providers needs a health check endpoint to know if the server is up otherwise they will stop the app
|
||||||
|
*/
|
||||||
|
http.createServer((_req, res) => {
|
||||||
|
res.writeHead(200, {'Content-Type': 'text/plain'});
|
||||||
|
res.write('Health check: OK');
|
||||||
|
res.end();
|
||||||
|
}).listen(variables.APP_PORT);
|
||||||
|
|
||||||
Container.get(CronService).archiveFiles();
|
Container.get(CronService).archiveFiles();
|
||||||
await Container.get(CronService).updateUsers();
|
await Container.get(CronService).updateUsers();
|
||||||
Container.get(CronService).checkDocumentsExpiration();
|
Container.get(CronService).checkDocumentsExpiration();
|
||||||
@ -17,6 +28,7 @@ import CronService from "@Services/common/CronService/CronService";
|
|||||||
Container.get(CronService).sendMails();
|
Container.get(CronService).sendMails();
|
||||||
Container.get(CronService).sendRecapMails();
|
Container.get(CronService).sendRecapMails();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user