@nxtedition/lib 19.8.16 → 19.8.17
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 +30 -1
- package/package.json +1 -2
package/app.js
CHANGED
|
@@ -7,7 +7,6 @@ import { Buffer } from 'node:buffer'
|
|
|
7
7
|
import { getDockerSecretsSync } from './docker-secrets.js'
|
|
8
8
|
import fp from 'lodash/fp.js'
|
|
9
9
|
import { isMainThread, parentPort, threadId } from 'node:worker_threads'
|
|
10
|
-
import toobusy from 'toobusy-js'
|
|
11
10
|
import deepstream from '@nxtedition/deepstream.io-client-js'
|
|
12
11
|
import { createLogger } from './logger.js'
|
|
13
12
|
import nconf from 'nconf'
|
|
@@ -216,7 +215,37 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
216
215
|
})
|
|
217
216
|
}
|
|
218
217
|
|
|
218
|
+
let toobusy
|
|
219
|
+
|
|
219
220
|
if (appConfig.toobusy) {
|
|
221
|
+
const { monitorEventLoopDelay } = require('node:perf_hooks')
|
|
222
|
+
|
|
223
|
+
const resolution = 10
|
|
224
|
+
const interval = 500
|
|
225
|
+
const maxLag = 70
|
|
226
|
+
|
|
227
|
+
let currentLag = 0
|
|
228
|
+
|
|
229
|
+
const histogram = monitorEventLoopDelay({ resolution })
|
|
230
|
+
histogram.enable()
|
|
231
|
+
|
|
232
|
+
setInterval(() => {
|
|
233
|
+
currentLag = Math.max(0, histogram.mean / 1e6 - resolution)
|
|
234
|
+
if (Number.isNaN(currentLag)) {
|
|
235
|
+
currentLag = Infinity
|
|
236
|
+
}
|
|
237
|
+
histogram.reset()
|
|
238
|
+
|
|
239
|
+
if (currentLag > 1e3) {
|
|
240
|
+
logger?.error({ currentLag }, 'lag')
|
|
241
|
+
} else {
|
|
242
|
+
logger?.warn({ currentLag }, 'lag')
|
|
243
|
+
}
|
|
244
|
+
}, interval).unref()
|
|
245
|
+
|
|
246
|
+
toobusy = () => currentLag > maxLag
|
|
247
|
+
toobusy.lag = () => currentLag
|
|
248
|
+
|
|
220
249
|
toobusy.onLag((currentLag) => {
|
|
221
250
|
if (currentLag > 1e3) {
|
|
222
251
|
logger.error({ currentLag }, 'lag')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "19.8.
|
|
3
|
+
"version": "19.8.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -102,7 +102,6 @@
|
|
|
102
102
|
"request-target": "^1.0.2",
|
|
103
103
|
"smpte-timecode": "^1.3.6",
|
|
104
104
|
"split-string": "^6.0.0",
|
|
105
|
-
"toobusy-js": "^0.5.1",
|
|
106
105
|
"undici": "^6.19.2",
|
|
107
106
|
"url-join": "^5.0.0"
|
|
108
107
|
},
|