From f592e852f2424922a204f5053ec9e41255b1c5d8 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Wed, 22 May 2024 10:09:16 +0100 Subject: [PATCH] refactor: Update logger.error statements for exiting node process --- Accounts/Serve.ts | 2 +- AdminDashboard/Serve.ts | 2 +- App/Index.ts | 2 +- CommonServer/Utils/StartServer.ts | 2 +- Dashboard/Serve.ts | 2 +- Ingestor/Index.ts | 2 +- IsolatedVM/Index.ts | 2 +- Nginx/Index.ts | 2 +- Probe/Index.ts | 2 +- Probe/Utils/Monitors/Monitor.ts | 28 +++++++++++++++++++++++++++- StatusPage/Serve.ts | 2 +- TestServer/Index.ts | 2 +- 12 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Accounts/Serve.ts b/Accounts/Serve.ts index 45ad2aa823..488231b0f9 100755 --- a/Accounts/Serve.ts +++ b/Accounts/Serve.ts @@ -30,7 +30,7 @@ const init: PromiseVoidFunction = async (): Promise => { init().catch((err: Error) => { logger.error(err); - logger.debug('Exiting node process'); + logger.error('Exiting node process'); process.exit(1); }); diff --git a/AdminDashboard/Serve.ts b/AdminDashboard/Serve.ts index 81eddbaff6..a2f89564c6 100755 --- a/AdminDashboard/Serve.ts +++ b/AdminDashboard/Serve.ts @@ -31,7 +31,7 @@ const init: PromiseVoidFunction = async (): Promise => { init().catch((err: Error) => { logger.error(err); - logger.debug('Exiting node process'); + logger.error('Exiting node process'); process.exit(1); }); diff --git a/App/Index.ts b/App/Index.ts index 75ad978375..a6a6900f9f 100755 --- a/App/Index.ts +++ b/App/Index.ts @@ -78,6 +78,6 @@ const init: PromiseVoidFunction = async (): Promise => { init().catch((err: Error) => { logger.error(err); - logger.debug('Exiting node process'); + logger.error('Exiting node process'); process.exit(1); }); diff --git a/CommonServer/Utils/StartServer.ts b/CommonServer/Utils/StartServer.ts index 828f438970..46e86f8ec9 100644 --- a/CommonServer/Utils/StartServer.ts +++ b/CommonServer/Utils/StartServer.ts @@ -146,7 +146,7 @@ const init: InitFunction = async ( ): Promise => { const { appName, port, isFrontendApp = false } = data; - logger.debug(`App Version: ${AppVersion.toString()}`); + logger.info(`App Version: ${AppVersion.toString()}`); await Express.launchApplication(appName, port); LocalCache.setString('app', 'name', appName); diff --git a/Dashboard/Serve.ts b/Dashboard/Serve.ts index 001f63c40a..139eda5644 100755 --- a/Dashboard/Serve.ts +++ b/Dashboard/Serve.ts @@ -31,7 +31,7 @@ const init: PromiseVoidFunction = async (): Promise => { init().catch((err: Error) => { logger.error(err); - logger.debug('Exiting node process'); + logger.error('Exiting node process'); process.exit(1); }); diff --git a/Ingestor/Index.ts b/Ingestor/Index.ts index 760962ada7..4e1bc1714a 100644 --- a/Ingestor/Index.ts +++ b/Ingestor/Index.ts @@ -74,6 +74,6 @@ const init: PromiseVoidFunction = async (): Promise => { init().catch((err: Error) => { logger.error(err); - logger.debug('Exiting node process'); + logger.error('Exiting node process'); process.exit(1); }); diff --git a/IsolatedVM/Index.ts b/IsolatedVM/Index.ts index c7789a9602..ac014650e9 100644 --- a/IsolatedVM/Index.ts +++ b/IsolatedVM/Index.ts @@ -36,6 +36,6 @@ const init: PromiseVoidFunction = async (): Promise => { init().catch((err: Error) => { logger.error(err); - logger.debug('Exiting node process'); + logger.error('Exiting node process'); process.exit(1); }); diff --git a/Nginx/Index.ts b/Nginx/Index.ts index 30f77a8575..ecd74f2b6e 100644 --- a/Nginx/Index.ts +++ b/Nginx/Index.ts @@ -48,6 +48,6 @@ const init: PromiseVoidFunction = async (): Promise => { init().catch((err: Error) => { logger.error(err); - logger.debug('Exiting node process'); + logger.error('Exiting node process'); process.exit(1); }); diff --git a/Probe/Index.ts b/Probe/Index.ts index ccbf718df0..f00949254a 100644 --- a/Probe/Index.ts +++ b/Probe/Index.ts @@ -71,6 +71,6 @@ const init: PromiseVoidFunction = async (): Promise => { init().catch((err: Error) => { logger.error(err); - logger.debug('Exiting node process'); + logger.error('Exiting node process'); process.exit(1); }); diff --git a/Probe/Utils/Monitors/Monitor.ts b/Probe/Utils/Monitors/Monitor.ts index 6a995d5736..894b089b5a 100644 --- a/Probe/Utils/Monitors/Monitor.ts +++ b/Probe/Utils/Monitors/Monitor.ts @@ -130,14 +130,20 @@ export default class MonitorUtil { failureCause: '', }; - if (!monitorStep.data || !monitorStep.data?.monitorDestination) { + if (!monitorStep.data) { return result; } + if ( monitor.monitorType === MonitorType.Ping || monitor.monitorType === MonitorType.IP ) { + + if (!monitorStep.data?.monitorDestination) { + return result; + } + if (LocalCache.getString('PROBE', 'PING_MONITORING') === 'PORT') { // probe is online but ping monitoring is blocked by the cloud provider. Fallback to port monitoring. @@ -178,6 +184,11 @@ export default class MonitorUtil { } if (monitor.monitorType === MonitorType.Port) { + + if (!monitorStep.data?.monitorDestination) { + return result; + } + if (!monitorStep.data?.monitorDestinationPort) { result.isOnline = false; result.responseTimeInMs = 0; @@ -249,6 +260,11 @@ export default class MonitorUtil { } if (monitor.monitorType === MonitorType.SSLCertificate) { + + if (!monitorStep.data?.monitorDestination) { + return result; + } + if (!monitorStep.data?.monitorDestination) { result.isOnline = false; result.responseTimeInMs = 0; @@ -277,6 +293,11 @@ export default class MonitorUtil { } if (monitor.monitorType === MonitorType.Website) { + + if (!monitorStep.data?.monitorDestination) { + return result; + } + const response: ProbeWebsiteResponse | null = await WebsiteMonitor.ping( monitorStep.data?.monitorDestination as URL, @@ -300,6 +321,11 @@ export default class MonitorUtil { } if (monitor.monitorType === MonitorType.API) { + + if (!monitorStep.data?.monitorDestination) { + return result; + } + let requestBody: JSONObject | undefined = undefined; if ( monitorStep.data?.requestBody && diff --git a/StatusPage/Serve.ts b/StatusPage/Serve.ts index cb759cb663..f05369d054 100644 --- a/StatusPage/Serve.ts +++ b/StatusPage/Serve.ts @@ -29,7 +29,7 @@ const init: PromiseVoidFunction = async (): Promise => { init().catch((err: Error) => { logger.error(err); - logger.debug('Exiting node process'); + logger.error('Exiting node process'); process.exit(1); }); diff --git a/TestServer/Index.ts b/TestServer/Index.ts index 7c0321f3f8..b3e4fb59bb 100644 --- a/TestServer/Index.ts +++ b/TestServer/Index.ts @@ -37,6 +37,6 @@ const init: PromiseVoidFunction = async (): Promise => { init().catch((err: Error) => { logger.error(err); - logger.debug('Exiting node process'); + logger.error('Exiting node process'); process.exit(1); });