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
14 changes: 14 additions & 0 deletions services/healthchecks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import axios from "axios";
import macros from "../utils/macros";

export async function sendHealthCheck(): Promise<void> {
/**
* 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(process.env.HEALTHCHECK_PING);
} catch (error) {
macros.warn("Health checks service is not responding properly: " + error);
}
}
5 changes: 5 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,10 @@ class Updater {
await this.sendUserNotifications(sections);
// Save the data in our database
await this.saveDataToDatabase(sections);
// Send out healthcheck ping in prod
if (macros.PROD) {
await sendHealthCheck();
}

const totalTime = Date.now() - startTime;
macros.log(
Expand Down
5 changes: 4 additions & 1 deletion template.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ CLIENT_ORIGIN=http://localhost:5000
JWT_SECRET=

# This is only used for local development
POSTGRES_PASSWORD=default_password
POSTGRES_PASSWORD=default_password

# Healtchecks ping server
HEALTHCHECK_PING = https://hc-ping.com/7d9197be-db67-4cc5-be00-1a3df56d0918
Loading