@nxtedition/lib 26.0.30 → 26.0.31
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 +10 -5
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -345,28 +345,33 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
345
345
|
allNodes.push(cpus)
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
|
|
349
|
-
|
|
348
|
+
let indices = []
|
|
349
|
+
if (Number.isInteger(appConfig.affinity)) {
|
|
350
|
+
indices = [appConfig.affinity % allNodes.length]
|
|
350
351
|
} else if (appConfig.affinity == null) {
|
|
351
|
-
|
|
352
|
+
indices = [hashString(serviceName) % allNodes.length]
|
|
352
353
|
} else {
|
|
353
354
|
throw new Error('invalid affinity configuration: ' + appConfig.affinity)
|
|
354
355
|
}
|
|
355
356
|
|
|
357
|
+
affinity = indices.flatMap((i) => allNodes[i] ?? [])
|
|
356
358
|
affinity = fp.uniq(affinity)
|
|
357
359
|
affinity = fp.intersection(affinity, sched_getaffinity(0))
|
|
358
360
|
|
|
359
361
|
if (
|
|
360
362
|
!Array.isArray(affinity) ||
|
|
361
363
|
affinity.length === 0 ||
|
|
362
|
-
affinity.some((x) =>
|
|
364
|
+
affinity.some((x) => !Number.isInteger(x) || x < 0)
|
|
363
365
|
) {
|
|
364
366
|
throw new Error('invalid affinity configuration: ' + appConfig.affinity)
|
|
365
367
|
}
|
|
366
368
|
|
|
367
369
|
try {
|
|
368
370
|
sched_setaffinity(0, affinity)
|
|
369
|
-
logger.debug(
|
|
371
|
+
logger.debug(
|
|
372
|
+
{ data: { value: appConfig.affinity, affinity, indices } },
|
|
373
|
+
'sched_setaffinity succeeded',
|
|
374
|
+
)
|
|
370
375
|
} catch (err) {
|
|
371
376
|
logger.error({ err }, 'sched_setaffinity failed')
|
|
372
377
|
}
|