Skip to content

Commit

Permalink
health-check webhook triggers only in production env
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Demidoff authored and Michael Demidoff committed Oct 22, 2024
1 parent 5041371 commit cb03ba7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codemod-com/backend",
"version": "0.0.160",
"version": "0.0.161",
"scripts": {
"build": "tsc && node esbuild.config.js",
"start": "node build/index.js",
Expand Down
26 changes: 16 additions & 10 deletions apps/backend/src/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const services: Array<{
type: "websocket",
available: true,
webhook:
" https://api.instatus.com/v3/integrations/webhook/clzbu558m93630kcn6fnvj8yk8",
"https://api.instatus.com/v3/integrations/webhook/clzbu558m93630kcn6fnvj8yk8",
},
{
name: "Run Service",
Expand Down Expand Up @@ -141,9 +141,11 @@ const systemHealthCheckCron = new CronJob(
const response = await axios.get(service.url);

if (response.status === 200 && service.available === false) {
await axios.post(service.webhook, {
trigger: "up",
});
if (env === "production") {
await axios.post(service.webhook, {
trigger: "up",
});
}

await web.chat.postMessage({
channel: channel,
Expand All @@ -157,9 +159,11 @@ const systemHealthCheckCron = new CronJob(

ws.on("open", async () => {
if (service.available === false) {
await axios.post(service.webhook, {
trigger: "up",
});
if (env === "production") {
await axios.post(service.webhook, {
trigger: "up",
});
}

await web.chat.postMessage({
channel: channel,
Expand All @@ -181,9 +185,11 @@ const systemHealthCheckCron = new CronJob(
}
} catch (error) {
if (service.available === true) {
await axios.post(service.webhook, {
trigger: "down",
});
if (env === "production") {
await axios.post(service.webhook, {
trigger: "down",
});
}

await web.chat.postMessage({
channel: channel,
Expand Down

0 comments on commit cb03ba7

Please sign in to comment.