Implement push monitoring

This commit is contained in:
2023-09-16 15:33:16 +02:00
parent 3594c2ea8c
commit c6a4577872
7 changed files with 425 additions and 197 deletions

View File

@ -1,6 +1,7 @@
import { runCleanup } from "../service";
import client from "./index";
import { initPromise } from "../data/dataSource";
import pushMonitor from "@astrogd/eu.astrogd.uptime-kuma-push-monitor";
const token = process.env["TOKEN"];
if (!token) throw new ReferenceError("TOKEN environment variable is missing");
@ -14,6 +15,9 @@ async function run() {
client.on("ready", async () => {
console.log(`Connected to Discord API. Bot account is ${client.user?.tag} (${client.user?.id})`);
if (process.env["MONITOR_URL"]) pushMonitor.register(process.env["MONITOR_URL"], 120);
pushMonitor.enableShutdownNotifications();
pushMonitor.setPerformanceHandler(() => client.ws.ping);
runCleanup();
});

View File

@ -1,4 +1,3 @@
import "./uptime";
import runCleanup from "./cleanup";
export {

View File

@ -1,19 +0,0 @@
import express from "express";
import pack from "../../package.json";
import startupTime from "../tools/startupTime";
const app = express();
app.get("/", (_req, res) => {
res.status(200).json({
running: true,
version: pack.version,
runningSince: startupTime.toISOString()
});
});
app.all("*", (_req, res) => {
res.status(404).end();
});
app.listen(80);