@nxtedition/lib 27.0.1 → 27.0.2
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 +43 -5
- package/numa.js +8 -1
- package/package.json +2 -2
package/app.js
CHANGED
|
@@ -371,11 +371,49 @@ export function makeApp(appConfig, onTerminateOrMeta, metaOrNull) {
|
|
|
371
371
|
numa = hashString(JSON.stringify({ serviceName, serviceModule }))
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
374
|
+
if (numa === 'net') {
|
|
375
|
+
if (config.hostname) {
|
|
376
|
+
ds.record
|
|
377
|
+
.observe(`${config.hostname}:monitor.stats?`, ds.record.PROVIDER)
|
|
378
|
+
.pipe(
|
|
379
|
+
rxjs.map((stats) => stats?.net?.bonding?.[0]?.numaNode ?? null),
|
|
380
|
+
rxjs.filter((n) => Number.isInteger(n) && n >= 0),
|
|
381
|
+
rxjs.timeout({
|
|
382
|
+
first: 10e3,
|
|
383
|
+
with: () => rxjs.of(null),
|
|
384
|
+
}),
|
|
385
|
+
rxjs.distinctUntilChanged(),
|
|
386
|
+
rxjs.retry({
|
|
387
|
+
resetOnSuccess: true,
|
|
388
|
+
delay(err, retryCount) {
|
|
389
|
+
logger.error({ err, retryCount }, 'net numa failed')
|
|
390
|
+
return rxjs.timer(10e3)
|
|
391
|
+
},
|
|
392
|
+
}),
|
|
393
|
+
)
|
|
394
|
+
.subscribe((numaNode) => {
|
|
395
|
+
if (numaNode != null) {
|
|
396
|
+
try {
|
|
397
|
+
affinity = numa.setAffinity(numaNode)
|
|
398
|
+
logger.debug(
|
|
399
|
+
{ hostname: config.hostname, numaNode, affinity },
|
|
400
|
+
'net numa succeeded',
|
|
401
|
+
)
|
|
402
|
+
} catch (err) {
|
|
403
|
+
logger.error({ err, hostname: config.hostname, numaNode }, 'net numa failed')
|
|
404
|
+
}
|
|
405
|
+
} else {
|
|
406
|
+
logger.warn({ hostname: config.hostname, numaNode }, 'net numa missing')
|
|
407
|
+
}
|
|
408
|
+
})
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
try {
|
|
412
|
+
affinity = setAffinity(numa)
|
|
413
|
+
logger.debug({ data: { numa: appConfig.numa, affinity } }, 'set numa affinity succeeded')
|
|
414
|
+
} catch (err) {
|
|
415
|
+
logger.error({ err, data: { numa: appConfig.numa } }, 'set numa affinity failed')
|
|
416
|
+
}
|
|
379
417
|
}
|
|
380
418
|
}
|
|
381
419
|
|
package/numa.js
CHANGED
|
@@ -4,10 +4,17 @@ import path from 'node:path'
|
|
|
4
4
|
import { sched_setaffinity } from '@nxtedition/sched'
|
|
5
5
|
|
|
6
6
|
function parseRange(value) {
|
|
7
|
+
if (typeof value !== 'string') {
|
|
8
|
+
throw new Error('CPU range must be a string')
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
const range = []
|
|
8
12
|
for (const part of value.split(',')) {
|
|
9
13
|
if (part.includes('-')) {
|
|
10
|
-
const [start, end] = part.split('-').map(Number)
|
|
14
|
+
const [start, end, ...rest] = part.split('-').map(Number)
|
|
15
|
+
if (rest.length > 0) {
|
|
16
|
+
throw new Error('Invalid CPU range')
|
|
17
|
+
}
|
|
11
18
|
for (let i = start; i <= end; i++) {
|
|
12
19
|
range.push(i)
|
|
13
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "27.0.
|
|
3
|
+
"version": "27.0.2",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"pino": ">=7.0.0",
|
|
88
88
|
"rxjs": "^7.0.0"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "ad258cea82e41d8d196fc344fd7436675abf70a0"
|
|
91
91
|
}
|