@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.
Files changed (2) hide show
  1. package/app.js +10 -5
  2. 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
- if (Number.isInteger(appConfig.affinity) && appConfig.affinity >= 0) {
349
- affinity = allNodes[appConfig.affinity % allNodes.length]
348
+ let indices = []
349
+ if (Number.isInteger(appConfig.affinity)) {
350
+ indices = [appConfig.affinity % allNodes.length]
350
351
  } else if (appConfig.affinity == null) {
351
- affinity = allNodes[hashString(serviceName) % allNodes.length]
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) => typeof x !== 'number' || x < 0)
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({ data: { value: appConfig.affinity, affinity } }, 'sched_setaffinity succeeded')
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "26.0.30",
3
+ "version": "26.0.31",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",