From 6c9eb6fec9831fc09954b3060c98391e1007decc Mon Sep 17 00:00:00 2001 From: Yanis JEDRZEJCZAK Date: Tue, 14 May 2024 17:11:56 +0200 Subject: [PATCH 1/2] Adding Health Check for cloud providers --- src/entries/Cron.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/entries/Cron.ts b/src/entries/Cron.ts index 760eaa9c..2ceb39da 100644 --- a/src/entries/Cron.ts +++ b/src/entries/Cron.ts @@ -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); } From e264420afa164a44b47cca2711c2dfd2ab609a94 Mon Sep 17 00:00:00 2001 From: Vins Date: Thu, 16 May 2024 11:49:19 +0200 Subject: [PATCH 2/2] Switch to new sentry account --- src/sentry.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sentry.config.ts b/src/sentry.config.ts index a921142d..b3715ede 100644 --- a/src/sentry.config.ts +++ b/src/sentry.config.ts @@ -5,7 +5,7 @@ import Container from "typedi"; const variables = Container.get(BackendVariables); Sentry.init({ - dsn: "https://ca6a89e8b480c814e1b5828b8412c681@o4506382103281664.ingest.sentry.io/4506399972130816", + dsn: "https://d4c51d58de2447f0db61730eb6f6185f@o4507265384972288.ingest.de.sentry.io/4507265396244560", // We recommend adjusting this value in production, or using tracesSampler // for finer control @@ -13,4 +13,4 @@ Sentry.init({ environment: variables.ENV, }); -Sentry.setTag("service", "leCoffre-back"); +Sentry.setTag("service", "lecoffre-back");