@nxtedition/lib 17.2.7 → 17.2.8
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/app.js +17 -16
- package/logger.js +6 -2
- package/package.json +2 -1
package/app.js
CHANGED
|
@@ -129,23 +129,24 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
129
129
|
base: loggerConfig?.base ? { ...loggerConfig.base } : {},
|
|
130
130
|
})
|
|
131
131
|
|
|
132
|
-
destroyers.push(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
)
|
|
137
|
-
|
|
132
|
+
destroyers.push(() => {
|
|
133
|
+
try {
|
|
134
|
+
logger.flushSync()
|
|
135
|
+
} catch (err) {
|
|
136
|
+
console.error(err)
|
|
137
|
+
}
|
|
138
|
+
})
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
let terminated = false
|
|
141
|
-
const terminate = async () => {
|
|
142
|
+
const terminate = async (reason) => {
|
|
142
143
|
if (terminated) {
|
|
143
144
|
return
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
terminated = true
|
|
147
148
|
|
|
148
|
-
logger.info('terminate')
|
|
149
|
+
logger.info({ reason }, 'terminate')
|
|
149
150
|
|
|
150
151
|
ac.abort()
|
|
151
152
|
|
|
@@ -157,11 +158,11 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
for (const { reason } of await Promise.allSettled(
|
|
161
|
+
for (const { reason: err } of await Promise.allSettled(
|
|
161
162
|
destroyers.filter(Boolean).map((fn) => fn(logger)),
|
|
162
163
|
)) {
|
|
163
|
-
if (
|
|
164
|
-
logger.error({ err
|
|
164
|
+
if (err) {
|
|
165
|
+
logger.error({ err }, 'shutdown error')
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
|
|
@@ -176,17 +177,17 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
process
|
|
179
|
-
.on('beforeExit', terminate)
|
|
180
|
-
.on('SIGINT', terminate)
|
|
181
|
-
.on('SIGTERM', terminate)
|
|
182
|
-
.on('uncaughtExceptionMonitor', terminate)
|
|
180
|
+
.on('beforeExit', () => terminate('beforeExit'))
|
|
181
|
+
.on('SIGINT', () => terminate('SIGINT'))
|
|
182
|
+
.on('SIGTERM', () => terminate('SIGTERM'))
|
|
183
|
+
.on('uncaughtExceptionMonitor', () => terminate('uncaughtExceptionMonitor'))
|
|
183
184
|
|
|
184
185
|
logger.debug({ data: JSON.stringify(config, null, 2) }, 'config')
|
|
185
186
|
|
|
186
187
|
if (!isMainThread && parentPort) {
|
|
187
188
|
parentPort.on('message', ({ type }) => {
|
|
188
189
|
if (type === 'nxt:worker:terminate') {
|
|
189
|
-
terminate()
|
|
190
|
+
terminate('nxt:worker:terminate')
|
|
190
191
|
}
|
|
191
192
|
})
|
|
192
193
|
}
|
package/logger.js
CHANGED
|
@@ -32,8 +32,12 @@ export function createLogger(
|
|
|
32
32
|
let flushing = 0
|
|
33
33
|
setInterval(() => {
|
|
34
34
|
if (flushing > 60) {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
try {
|
|
36
|
+
logger.warn('logger is flushing too slow')
|
|
37
|
+
stream.flushSync()
|
|
38
|
+
} catch (err) {
|
|
39
|
+
console.error(err)
|
|
40
|
+
}
|
|
37
41
|
} else {
|
|
38
42
|
flushing++
|
|
39
43
|
stream.flush(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "17.2.
|
|
3
|
+
"version": "17.2.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"nconf": "^0.12.1",
|
|
90
90
|
"nested-error-stacks": "^2.1.1",
|
|
91
91
|
"object-hash": "^3.0.0",
|
|
92
|
+
"pino": "^8.17.2",
|
|
92
93
|
"pino-std-serializers": "^6.2.2",
|
|
93
94
|
"qs": "^6.11.1",
|
|
94
95
|
"request-target": "^1.0.2",
|