oneuptime/Probe/Config.ts

57 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-05-05 12:02:23 +00:00
import URL from 'Common/Types/API/URL';
2023-05-03 10:54:25 +00:00
import logger from 'CommonServer/Utils/Logger';
2023-05-05 12:02:23 +00:00
import ObjectID from 'Common/Types/ObjectID';
2023-05-03 10:54:25 +00:00
2023-10-09 17:54:23 +00:00
if (!process.env['INGESTOR_URL']) {
logger.error('INGESTOR_URL is not set');
2023-05-03 10:54:25 +00:00
process.exit();
}
2023-10-14 11:01:06 +00:00
export let INGESTOR_URL: URL = URL.fromString(
process.env['INGESTOR_URL'] || 'https://oneuptime.com'
);
2023-09-22 15:36:04 +00:00
// If probe api does not have the path. Add it.
if (
2023-10-09 17:54:23 +00:00
!INGESTOR_URL.toString().endsWith('ingestor') &&
!INGESTOR_URL.toString().endsWith('ingestor/')
2023-09-22 15:36:04 +00:00
) {
2023-10-09 17:54:23 +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-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
2023-05-05 12:02:23 +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
2023-05-05 12:02:23 +00:00
if (!process.env['PROBE_KEY']) {
logger.error('PROBE_KEY is not set');
2023-05-03 10:54:25 +00:00
process.exit();
}
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;
if (typeof probeMonitoringWorkers === 'string') {
probeMonitoringWorkers = parseInt(probeMonitoringWorkers);
}
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'] || 1;
if (typeof monitorFetchLimit === 'string') {
monitorFetchLimit = parseInt(monitorFetchLimit);
}
export const PROBE_MONITOR_FETCH_LIMIT: number = monitorFetchLimit;