feat: add configurable port for probe services and update initialization

This commit is contained in:
Simon Larsen
2025-01-01 18:04:19 +00:00
parent a0d33bf9c1
commit f1afab0b52
4 changed files with 9 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
import URL from "Common/Types/API/URL";
import ObjectID from "Common/Types/ObjectID";
import logger from "Common/Server/Utils/Logger";
import Port from "Common/Types/Port";
if (!process.env["PROBE_INGEST_URL"] && !process.env["ONEUPTIME_URL"]) {
logger.error("PROBE_INGEST_URL or ONEUPTIME_URL is not set");
@@ -79,3 +80,5 @@ export const PROBE_MONITOR_RETRY_LIMIT: number = process.env[
]
? parseInt(process.env["PROBE_MONITOR_RETRY_LIMIT"].toString())
: 3;
export const PORT: Port = new Port(process.env["PORT"] ? parseInt(process.env["PORT"]) : 3874);

View File

@@ -1,4 +1,4 @@
import { PROBE_MONITOR_RETRY_LIMIT, PROBE_MONITORING_WORKERS } from "./Config";
import { PORT, PROBE_MONITOR_RETRY_LIMIT, PROBE_MONITORING_WORKERS } from "./Config";
import "./Jobs/Alive";
import FetchListAndProbe from "./Jobs/Monitor/FetchList";
import FetchMonitorTest from "./Jobs/Monitor/FetchMonitorTest";
@@ -9,7 +9,6 @@ import logger from "Common/Server/Utils/Logger";
import App from "Common/Server/Utils/StartServer";
import Telemetry from "Common/Server/Utils/Telemetry";
import "ejs";
import Port from "Common/Types/Port";
const APP_NAME: string = "probe";
@@ -23,7 +22,7 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
// init the app
await App.init({
appName: APP_NAME,
port: new Port(3874), // some random port to start the server. Since this is the probe, it doesn't need to be exposed.
port: PORT, // some random port to start the server. Since this is the probe, it doesn't need to be exposed.
isFrontendApp: false,
statusOptions: {
liveCheck: async () => {},

View File

@@ -182,7 +182,7 @@ GLOBAL_PROBE_1_MONITOR_FETCH_LIMIT=10
GLOBAL_PROBE_1_ONEUPTIME_URL=http://localhost
GLOBAL_PROBE_1_SYNTHETIC_MONITOR_SCRIPT_TIMEOUT_IN_MS=60000
GLOBAL_PROBE_1_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS=60000
GLOBAL_PROBE_1_PORT=3874
GLOBAL_PROBE_2_NAME="Probe-2"
GLOBAL_PROBE_2_DESCRIPTION="Global probe to monitor oneuptime resources"
@@ -191,6 +191,7 @@ GLOBAL_PROBE_2_MONITOR_FETCH_LIMIT=10
GLOBAL_PROBE_2_ONEUPTIME_URL=http://localhost
GLOBAL_PROBE_2_SYNTHETIC_MONITOR_SCRIPT_TIMEOUT_IN_MS=60000
GLOBAL_PROBE_2_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS=60000
GLOBAL_PROBE_2_PORT=3875
SMS_DEFAULT_COST_IN_CENTS=
CALL_DEFAULT_COST_IN_CENTS_PER_MINUTE=

View File

@@ -367,6 +367,7 @@ services:
ONEUPTIME_URL: ${GLOBAL_PROBE_1_ONEUPTIME_URL}
PROBE_MONITOR_FETCH_LIMIT: ${GLOBAL_PROBE_1_MONITOR_FETCH_LIMIT}
DISABLE_TELEMETRY: ${DISABLE_TELEMETRY_FOR_PROBE}
PORT: ${GLOBAL_PROBE_1_PORT}
logging:
driver: "local"
options:
@@ -386,6 +387,7 @@ services:
PROBE_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS: ${GLOBAL_PROBE_2_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS}
PROBE_MONITOR_FETCH_LIMIT: ${GLOBAL_PROBE_2_MONITOR_FETCH_LIMIT}
DISABLE_TELEMETRY: ${DISABLE_TELEMETRY_FOR_PROBE}
PORT: ${GLOBAL_PROBE_2_PORT}
logging:
driver: "local"
options: