IO-2959 Implement logger & best practices.
This commit is contained in:
@@ -22,7 +22,7 @@ const { applyIOHelpers } = require("./server/utils/ioHelpers");
|
||||
const { redisSocketEvents } = require("./server/web-sockets/redisSocketEvents");
|
||||
const { ElastiCacheClient, DescribeCacheClustersCommand } = require("@aws-sdk/client-elasticache");
|
||||
const { InstanceRegion } = require("./server/utils/instanceMgr");
|
||||
const { StartStatusReporter } = require("./server/utils/statusReporter");
|
||||
const StartStatusReporter = require("./server/utils/statusReporter");
|
||||
|
||||
const CLUSTER_RETRY_BASE_DELAY = 100;
|
||||
const CLUSTER_RETRY_MAX_DELAY = 5000;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// Load environment variables THIS MUST BE AT THE TOP
|
||||
const path = require("path");
|
||||
const getHostNameOrIP = require("./getHostNameOrIP");
|
||||
const logger = require("./logger");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(process.cwd(), `.env.${process.env.NODE_ENV || "development"}`)
|
||||
});
|
||||
const CrispStatusReporter = require("crisp-status-reporter").CrispStatusReporter;
|
||||
const InstanceManager = require("../utils/instanceMgr").default;
|
||||
|
||||
exports.StartStatusReporter = function () {
|
||||
function StartStatusReporter() {
|
||||
//For ImEX Online.
|
||||
|
||||
InstanceManager({
|
||||
executeFunction: true,
|
||||
debug: true,
|
||||
args: [],
|
||||
imex: () => {
|
||||
if (
|
||||
@@ -21,16 +21,32 @@ exports.StartStatusReporter = function () {
|
||||
!process.env.CRISP_SERVICE_IDENTIFIER ||
|
||||
!process.env.CRISP_NODE_IDENTIFIER
|
||||
) {
|
||||
logger.log("crisp-status-update-error", "DEBUG", null, null, { message: "Environment Variables not set." });
|
||||
return;
|
||||
}
|
||||
var crispStatusReporter = new CrispStatusReporter({
|
||||
token: process.env.CRISP_SECRET_TOKEN, // Your reporter token (given by Crisp)
|
||||
service_id: process.env.CRISP_SERVICE_IDENTIFIER, // Service ID containing the parent Node for Replica (given by Crisp)
|
||||
node_id: process.env.CRISP_NODE_IDENTIFIER, // Node ID containing Replica (given by Crisp)
|
||||
replica_id: getHostNameOrIP(), // Unique Replica ID for instance (ie. your IP on the LAN)
|
||||
interval: 30, // Reporting interval (in seconds; defaults to 30 seconds if not set)
|
||||
console: require("console") // Console instance if you need to debug issues,
|
||||
});
|
||||
|
||||
try {
|
||||
const crispStatusReporter = new CrispStatusReporter({
|
||||
token: process.env.CRISP_SECRET_TOKEN, // Your reporter token (given by Crisp)
|
||||
service_id: process.env.CRISP_SERVICE_IDENTIFIER, // Service ID containing the parent Node for Replica (given by Crisp)
|
||||
node_id: process.env.CRISP_NODE_IDENTIFIER, // Node ID containing Replica (given by Crisp)
|
||||
replica_id: getHostNameOrIP(), // Unique Replica ID for instance (ie. your IP on the LAN)
|
||||
interval: 30, // Reporting interval (in seconds; defaults to 30 seconds if not set)
|
||||
|
||||
console: {
|
||||
debug: (log_message, data) => logger.log("crisp-status-update", "DEBUG", null, null, { log_message, data }),
|
||||
log: (log_message, data) => logger.log("crisp-status-update", "DEBUG", null, null, { log_message, data }),
|
||||
warn: (log_message, data) => logger.log("crisp-status-update", "WARN", null, null, { log_message, data }),
|
||||
error: (log_message, data) => logger.log("crisp-status-update", "ERROR", null, null, { log_message, data })
|
||||
} // Console instance if you need to debug issues,
|
||||
});
|
||||
|
||||
return crispStatusReporter;
|
||||
} catch (error) {
|
||||
logger.log("crisp-status-update-error", "DEBUG", null, null, { error: error.message });
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = StartStatusReporter;
|
||||
|
||||
Reference in New Issue
Block a user