Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updater healthcheck #237

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
15 changes: 15 additions & 0 deletions services/healthchecks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios from "axios";
import macros from "../utils/macros";

export async function sendHealthCheck(): Promise<void> {
const pingURL = " https://hc-ping.com/7d9197be-db67-4cc5-be00-1a3df56d0918";
mehallhm marked this conversation as resolved.
Show resolved Hide resolved
/**
* Sends out a ping to the pingURL, if there is an error with the updater,
* a message will be sent to the Search-Support channel in the sandbox slack.
*/
try {
await axios.get(pingURL);
} catch (error) {
macros.warn("Health checks service is not responding properly: " + error);
}
}
3 changes: 3 additions & 0 deletions services/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from "../types/scraperTypes";
import processor from "../scrapers/classes/main";
import filters from "../scrapers/filters";
import { sendHealthCheck } from "./healthchecks";

/*
At most, there are 12 terms that we want to update - if we're in the spring & summer semesters have been posted
Expand Down Expand Up @@ -362,6 +363,8 @@ class Updater {
await this.sendUserNotifications(sections);
// Save the data in our database
await this.saveDataToDatabase(sections);
// Send out healthcheck ping
macros.PROD ? await sendHealthCheck() : null;
mehallhm marked this conversation as resolved.
Show resolved Hide resolved

const totalTime = Date.now() - startTime;
macros.log(
Expand Down
Loading