@justair/justair-library 4.8.4-alpha → 4.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/config/logger.js
CHANGED
|
@@ -40,104 +40,6 @@ class CustomLogger {
|
|
|
40
40
|
getLogger() {
|
|
41
41
|
return this.logger;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
_getServiceMetadata() {
|
|
45
|
-
return {
|
|
46
|
-
service: this.APPLICATION_NAME,
|
|
47
|
-
env: process.env.NODE_ENV || 'production',
|
|
48
|
-
version: process.env.K_REVISION || process.env.npm_package_version || 'unknown',
|
|
49
|
-
k_service: process.env.K_SERVICE,
|
|
50
|
-
k_revision: process.env.K_REVISION,
|
|
51
|
-
k_configuration: process.env.K_CONFIGURATION,
|
|
52
|
-
pod: process.env.HOSTNAME || process.env.POD_NAME,
|
|
53
|
-
namespace: process.env.NAMESPACE,
|
|
54
|
-
node: process.env.NODE_NAME,
|
|
55
|
-
pid: process.pid,
|
|
56
|
-
nodeVersion: process.version,
|
|
57
|
-
platform: process.platform,
|
|
58
|
-
timestamp: new Date().toISOString()
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
logServiceStartup(metadata = {}) {
|
|
63
|
-
this.logger.info('Service startup', {
|
|
64
|
-
event: 'service.startup',
|
|
65
|
-
...this._getServiceMetadata(),
|
|
66
|
-
...metadata
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
logGracefulShutdown(signal, metadata = {}) {
|
|
71
|
-
this.logger.info('Graceful shutdown initiated', {
|
|
72
|
-
event: 'service.shutdown.graceful',
|
|
73
|
-
signal,
|
|
74
|
-
...this._getServiceMetadata(),
|
|
75
|
-
...metadata
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
logCrash(error, source, metadata = {}) {
|
|
80
|
-
this.logger.error('Service crash detected', {
|
|
81
|
-
event: 'service.crash',
|
|
82
|
-
source,
|
|
83
|
-
error: {
|
|
84
|
-
message: error.message,
|
|
85
|
-
stack: error.stack,
|
|
86
|
-
name: error.name
|
|
87
|
-
},
|
|
88
|
-
...this._getServiceMetadata(),
|
|
89
|
-
...metadata
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
logExit(code, metadata = {}) {
|
|
94
|
-
this.logger.info('Service exit', {
|
|
95
|
-
event: 'service.exit',
|
|
96
|
-
exitCode: code,
|
|
97
|
-
...this._getServiceMetadata(),
|
|
98
|
-
...metadata
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
setupLifecycleHooks() {
|
|
103
|
-
// Startup
|
|
104
|
-
this.logServiceStartup();
|
|
105
|
-
|
|
106
|
-
// Graceful shutdown signals
|
|
107
|
-
const shutdownHandler = (signal) => {
|
|
108
|
-
this.logGracefulShutdown(signal);
|
|
109
|
-
// Allow logs to flush before exiting
|
|
110
|
-
setTimeout(() => process.exit(0), 1000);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
process.on('SIGTERM', () => shutdownHandler('SIGTERM'));
|
|
114
|
-
process.on('SIGINT', () => shutdownHandler('SIGINT'));
|
|
115
|
-
|
|
116
|
-
// Crash handlers
|
|
117
|
-
process.on('uncaughtException', (error) => {
|
|
118
|
-
this.logCrash(error, 'uncaughtException');
|
|
119
|
-
// Allow logs to flush before exiting
|
|
120
|
-
setTimeout(() => process.exit(1), 1000);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
process.on('unhandledRejection', (reason, promise) => {
|
|
124
|
-
const error = reason instanceof Error ? reason : new Error(String(reason));
|
|
125
|
-
this.logCrash(error, 'unhandledRejection', { promise: String(promise) });
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// Exit events
|
|
129
|
-
process.on('beforeExit', (code) => {
|
|
130
|
-
this.logger.info('Before exit', {
|
|
131
|
-
event: 'service.beforeExit',
|
|
132
|
-
exitCode: code,
|
|
133
|
-
...this._getServiceMetadata()
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
process.on('exit', (code) => {
|
|
138
|
-
this.logExit(code);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
43
|
}
|
|
142
44
|
|
|
143
45
|
export default CustomLogger;
|
package/src/models/alerts.js
CHANGED
|
@@ -35,12 +35,7 @@ const alertsSchema = mongoose.Schema(
|
|
|
35
35
|
recipients: [recipientSchema],
|
|
36
36
|
metaData: Object,
|
|
37
37
|
flaggedDataCompleteness: [Object],
|
|
38
|
-
flaggedMeasurementIds: [
|
|
39
|
-
{
|
|
40
|
-
type: mongoose.Types.ObjectId,
|
|
41
|
-
ref: "Measurements",
|
|
42
|
-
},
|
|
43
|
-
],
|
|
38
|
+
flaggedMeasurementIds: [Object],
|
|
44
39
|
},
|
|
45
40
|
{
|
|
46
41
|
timestamps: true,
|
|
@@ -18,6 +18,7 @@ const monitorSuppliersSchema = mongoose.Schema(
|
|
|
18
18
|
defaultParameterThresholds: Object,
|
|
19
19
|
defaultCompletenessThresholdCount: Number,
|
|
20
20
|
runFrequencyMinutes: { type: Number, default: 5 },
|
|
21
|
+
aqiRunMinute: { type: Number, default: 5 },
|
|
21
22
|
lastSuccessfulRun: Date,
|
|
22
23
|
lastFailedRun: Date,
|
|
23
24
|
rateLimits: [
|