refactor: Update logger.error statements for exiting node process

This commit is contained in:
Simon Larsen 2024-05-22 10:09:16 +01:00
parent a5f05376b0
commit f592e852f2
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
12 changed files with 38 additions and 12 deletions

View File

@ -30,7 +30,7 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
init().catch((err: Error) => {
logger.error(err);
logger.debug('Exiting node process');
logger.error('Exiting node process');
process.exit(1);
});

View File

@ -31,7 +31,7 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
init().catch((err: Error) => {
logger.error(err);
logger.debug('Exiting node process');
logger.error('Exiting node process');
process.exit(1);
});

View File

@ -78,6 +78,6 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
init().catch((err: Error) => {
logger.error(err);
logger.debug('Exiting node process');
logger.error('Exiting node process');
process.exit(1);
});

View File

@ -146,7 +146,7 @@ const init: InitFunction = async (
): Promise<ExpressApplication> => {
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);

View File

@ -31,7 +31,7 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
init().catch((err: Error) => {
logger.error(err);
logger.debug('Exiting node process');
logger.error('Exiting node process');
process.exit(1);
});

View File

@ -74,6 +74,6 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
init().catch((err: Error) => {
logger.error(err);
logger.debug('Exiting node process');
logger.error('Exiting node process');
process.exit(1);
});

View File

@ -36,6 +36,6 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
init().catch((err: Error) => {
logger.error(err);
logger.debug('Exiting node process');
logger.error('Exiting node process');
process.exit(1);
});

View File

@ -48,6 +48,6 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
init().catch((err: Error) => {
logger.error(err);
logger.debug('Exiting node process');
logger.error('Exiting node process');
process.exit(1);
});

View File

@ -71,6 +71,6 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
init().catch((err: Error) => {
logger.error(err);
logger.debug('Exiting node process');
logger.error('Exiting node process');
process.exit(1);
});

View File

@ -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 &&

View File

@ -29,7 +29,7 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
init().catch((err: Error) => {
logger.error(err);
logger.debug('Exiting node process');
logger.error('Exiting node process');
process.exit(1);
});

View File

@ -37,6 +37,6 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
init().catch((err: Error) => {
logger.error(err);
logger.debug('Exiting node process');
logger.error('Exiting node process');
process.exit(1);
});