oneuptime/Probe/Config.ts

74 lines
2.2 KiB
TypeScript
Raw Normal View History

import URL from "Common/Types/API/URL";
import ObjectID from "Common/Types/ObjectID";
import logger from "CommonServer/Utils/Logger";
2023-05-03 10:54:25 +00:00
if (!process.env["INGESTOR_URL"] && !process.env["ONEUPTIME_URL"]) {
logger.error("INGESTOR_URL or ONEUPTIME_URL is not set");
process.exit();
2023-05-03 10:54:25 +00:00
}
2023-10-14 11:01:06 +00:00
export let INGESTOR_URL: URL = URL.fromString(
process.env["ONEUPTIME_URL"] ||
process.env["INGESTOR_URL"] ||
"https://oneuptime.com",
2023-10-14 11:01:06 +00:00
);
2023-09-22 15:36:04 +00:00
// If probe api does not have the path. Add it.
if (
!INGESTOR_URL.toString().endsWith("ingestor") &&
!INGESTOR_URL.toString().endsWith("ingestor/")
2023-09-22 15:36:04 +00:00
) {
INGESTOR_URL = URL.fromString(INGESTOR_URL.addRoute("/ingestor").toString());
2023-09-22 15:36:04 +00:00
}
2023-05-03 10:54:25 +00:00
export const PROBE_NAME: string | null = process.env["PROBE_NAME"] || null;
2023-05-03 10:54:25 +00:00
2023-05-05 12:02:23 +00:00
export const PROBE_DESCRIPTION: string | null =
process.env["PROBE_DESCRIPTION"] || null;
2023-05-03 10:54:25 +00:00
export const PROBE_ID: ObjectID | null = process.env["PROBE_ID"]
? new ObjectID(process.env["PROBE_ID"])
: null;
2023-05-03 10:54:25 +00:00
if (!process.env["PROBE_KEY"]) {
logger.error("PROBE_KEY is not set");
process.exit();
2023-05-03 10:54:25 +00:00
}
export const PROBE_KEY: string = process.env["PROBE_KEY"];
2023-08-06 20:54:12 +00:00
let probeMonitoringWorkers: string | number =
process.env["PROBE_MONITORING_WORKERS"] || 1;
2023-08-06 20:54:12 +00:00
if (typeof probeMonitoringWorkers === "string") {
probeMonitoringWorkers = parseInt(probeMonitoringWorkers);
2023-08-06 20:54:12 +00:00
}
export const PROBE_MONITORING_WORKERS: number = probeMonitoringWorkers;
2023-08-07 14:22:45 +00:00
let monitorFetchLimit: string | number =
process.env["PROBE_MONITOR_FETCH_LIMIT"] || 10;
2023-08-07 14:22:45 +00:00
if (typeof monitorFetchLimit === "string") {
monitorFetchLimit = parseInt(monitorFetchLimit);
2023-08-07 14:22:45 +00:00
}
export const PROBE_MONITOR_FETCH_LIMIT: number = monitorFetchLimit;
export const HOSTNAME: string = process.env["HOSTNAME"] || "localhost";
export const PROBE_SYNTHETIC_MONITOR_SCRIPT_TIMEOUT_IN_MS: number = process.env[
"PROBE_SYNTHETIC_MONITOR_SCRIPT_TIMEOUT_IN_MS"
]
? parseInt(
process.env["PROBE_SYNTHETIC_MONITOR_SCRIPT_TIMEOUT_IN_MS"].toString(),
)
: 60000;
export const PROBE_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS: number = process
.env["PROBE_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS"]
? parseInt(
process.env["PROBE_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS"].toString(),
)
: 60000;