From 69ab60f4ddb0296d64b16628bbe087daa497d6d7 Mon Sep 17 00:00:00 2001 From: Philenst <20720278+Philenst@users.noreply.github.com> Date: Thu, 26 Sep 2024 12:21:55 +0100 Subject: [PATCH] Add healthcheck endpoint --- config.example.js | 3 ++- modules/cron.js | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config.example.js b/config.example.js index 3d95238..531c71e 100644 --- a/config.example.js +++ b/config.example.js @@ -18,4 +18,5 @@ export const fetchRate = 60 //minutes between each fetch export const host = "127.0.0.1" //use 0.0.0.0 as alternative export const port = 2345 export const trackerWebhook = "" -export const trackerUpdateWebhook = "" \ No newline at end of file +export const trackerUpdateWebhook = "" +export const healthCheckEndpoint = "" \ No newline at end of file diff --git a/modules/cron.js b/modules/cron.js index 0cee49f..787469d 100644 --- a/modules/cron.js +++ b/modules/cron.js @@ -2,7 +2,7 @@ import { fetchRate } from "../config.js"; import database from "../helper/database.js"; import { getUser, fillCache, updated } from "./fetch.js"; import Logger from "cutesy.js" -import { trackerUpdateWebhook } from "../config.js"; +import { trackerUpdateWebhook, healthCheckEndpoint } from "../config.js"; import { WebhookClient, EmbedBuilder } from 'discord.js' const webhookClient = new WebhookClient({ url: trackerUpdateWebhook }) const logger = new Logger().addTimestamp("hh:mm:ss").changeTag("Fetch").purple() @@ -42,6 +42,9 @@ function update(){ updated.scores = 0; logger.send("Finished update.") locked = false; + if (healthCheckEndpoint) { + await fetch(healthCheckEndpoint) + } return resolve() }) }