Adding Health Check for cloud providers
This commit is contained in:
parent
17ec583553
commit
e04517181b
@ -4,12 +4,23 @@ import "reflect-metadata";
|
||||
import { Container } from "typedi";
|
||||
import { BackendVariables } from "@Common/config/variables/Variables";
|
||||
import CronService from "@Services/common/CronService/CronService";
|
||||
import http from "http";
|
||||
|
||||
(async () => {
|
||||
console.info("Cron started");
|
||||
|
||||
try {
|
||||
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();
|
||||
await Container.get(CronService).updateUsers();
|
||||
Container.get(CronService).checkDocumentsExpiration();
|
||||
@ -17,6 +28,7 @@ import CronService from "@Services/common/CronService/CronService";
|
||||
Container.get(CronService).sendMails();
|
||||
Container.get(CronService).sendRecapMails();
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user