Skip to content

Commit

Permalink
feat: add configurable port for probe services and update initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Jan 1, 2025
1 parent a0d33bf commit f1afab0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Probe/Config.ts
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -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);
5 changes: 2 additions & 3 deletions Probe/Index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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";

Expand All @@ -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 () => {},
Expand Down
3 changes: 2 additions & 1 deletion config.example.env
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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=
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit f1afab0

Please sign in to comment.