@nxtedition/lib 27.0.11 → 27.1.0
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 +24 -0
- package/package.json +4 -3
package/app.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
resourceLimits,
|
|
20
20
|
} from 'node:worker_threads'
|
|
21
21
|
|
|
22
|
+
import { createFlamegraphMiddleware } from 'flamegraph-middleware'
|
|
22
23
|
import { getDockerSecretsSync } from './docker-secrets.js'
|
|
23
24
|
import { getUTCRangeForLocalTime } from './time.js'
|
|
24
25
|
import fp from 'lodash/fp.js'
|
|
@@ -1020,6 +1021,29 @@ export function makeApp(appConfig, onTerminateOrMeta, metaOrNull) {
|
|
|
1020
1021
|
}
|
|
1021
1022
|
}
|
|
1022
1023
|
|
|
1024
|
+
if (appConfig.profile !== false && !cluster.isWorker) {
|
|
1025
|
+
// TODO (fix): What about cluster?
|
|
1026
|
+
|
|
1027
|
+
const flamegraph = createFlamegraphMiddleware({
|
|
1028
|
+
basePath: '/profile',
|
|
1029
|
+
logger,
|
|
1030
|
+
...appConfig.profile,
|
|
1031
|
+
})
|
|
1032
|
+
|
|
1033
|
+
const server = http
|
|
1034
|
+
.createServer((req, res) => {
|
|
1035
|
+
flamegraph(req, res, () => {
|
|
1036
|
+
res.statusCode = 404
|
|
1037
|
+
res.end()
|
|
1038
|
+
})
|
|
1039
|
+
})
|
|
1040
|
+
.listen(appConfig.profile?.port ?? 40000 + threadId)
|
|
1041
|
+
.once('listening', () => logger.debug({ port: server.address().port }, 'profile listening'))
|
|
1042
|
+
.unref()
|
|
1043
|
+
|
|
1044
|
+
destroyers.unshift(() => new Promise((resolve) => server.close(resolve)))
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1023
1047
|
if (appConfig.inspect !== false && !cluster.isWorker) {
|
|
1024
1048
|
// TODO (fix): What about cluster?
|
|
1025
1049
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "27.0
|
|
3
|
+
"version": "27.1.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -52,11 +52,12 @@
|
|
|
52
52
|
"@elastic/transport": "^8.9.3",
|
|
53
53
|
"@nxtedition/nxt-undici": "^7.1.4",
|
|
54
54
|
"@nxtedition/sched": "^1.0.2",
|
|
55
|
-
"@nxtedition/template": "^1.0.
|
|
55
|
+
"@nxtedition/template": "^1.0.5",
|
|
56
56
|
"@nxtedition/weak-cache": "^1.0.1",
|
|
57
57
|
"diff": "5.2.0",
|
|
58
58
|
"eslint": "^9.38.0",
|
|
59
59
|
"fast-querystring": "^1.1.2",
|
|
60
|
+
"flamegraph-middleware": "https://github.com/Qard/flamegraph-middleware",
|
|
60
61
|
"http-errors": "^2.0.0",
|
|
61
62
|
"lerna": "^9.0.0",
|
|
62
63
|
"lodash": "^4.17.21",
|
|
@@ -93,5 +94,5 @@
|
|
|
93
94
|
"pino": ">=7.0.0",
|
|
94
95
|
"rxjs": "^7.0.0"
|
|
95
96
|
},
|
|
96
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "71bea4849f5a3e2dd5f9209eadec89e01393d0fd"
|
|
97
98
|
}
|