@nxtedition/lib 27.0.2 → 27.0.3

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 +57 -55
  2. package/package.json +2 -2
package/app.js CHANGED
@@ -363,60 +363,6 @@ export function makeApp(appConfig, onTerminateOrMeta, metaOrNull) {
363
363
  }
364
364
  }
365
365
 
366
- let affinity = null
367
-
368
- if (process.platform === 'linux' && appConfig.numa != null && appConfig.numa !== '') {
369
- let numa = appConfig.numa
370
- if (numa == 'auto' || numa === true) {
371
- numa = hashString(JSON.stringify({ serviceName, serviceModule }))
372
- }
373
-
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
- }
417
- }
418
- }
419
-
420
366
  if (appConfig.toobusy) {
421
367
  const resolution = appConfig.toobusy.resolution ?? 10
422
368
  const interval = appConfig.toobusy.interval ?? 500
@@ -614,6 +560,63 @@ export function makeApp(appConfig, onTerminateOrMeta, metaOrNull) {
614
560
  appDestroyers.unshift(() => ds.close())
615
561
  }
616
562
 
563
+ if (process.platform === 'linux' && appConfig.numa != null && appConfig.numa !== '') {
564
+ let numa = appConfig.numa
565
+ if (numa == 'auto' || numa === true) {
566
+ numa = hashString(
567
+ JSON.stringify({ serviceName, serviceModule, serviceInstanceId, serviceWorkerId }),
568
+ )
569
+ }
570
+
571
+ if (numa === 'net') {
572
+ if (config.hostname) {
573
+ if (!ds) {
574
+ throw new Error('deepstream is required for net numa')
575
+ }
576
+ ds.record
577
+ .observe(`${config.hostname}:monitor.stats?`, ds.record.PROVIDER)
578
+ .pipe(
579
+ rxjs.map((stats) => stats?.net?.bonding?.[0]?.numaNode ?? null),
580
+ rxjs.filter((n) => Number.isInteger(n) && n >= 0),
581
+ rxjs.timeout({
582
+ first: 10e3,
583
+ with: () => rxjs.of(null),
584
+ }),
585
+ rxjs.distinctUntilChanged(),
586
+ rxjs.retry({
587
+ resetOnSuccess: true,
588
+ delay(err, retryCount) {
589
+ logger.error({ err, retryCount }, 'net numa failed')
590
+ return rxjs.timer(10e3)
591
+ },
592
+ }),
593
+ )
594
+ .subscribe((numaNode) => {
595
+ if (numaNode != null) {
596
+ try {
597
+ const affinity = numa.setAffinity(numaNode)
598
+ logger.debug(
599
+ { hostname: config.hostname, numaNode, affinity },
600
+ 'net numa succeeded',
601
+ )
602
+ } catch (err) {
603
+ logger.error({ err, hostname: config.hostname, numaNode }, 'net numa failed')
604
+ }
605
+ } else {
606
+ logger.warn({ hostname: config.hostname, numaNode }, 'net numa missing')
607
+ }
608
+ })
609
+ }
610
+ } else {
611
+ try {
612
+ const affinity = setAffinity(numa)
613
+ logger.debug({ data: { numa: appConfig.numa, affinity } }, 'set numa affinity succeeded')
614
+ } catch (err) {
615
+ logger.error({ err, data: { numa: appConfig.numa } }, 'set numa affinity failed')
616
+ }
617
+ }
618
+ }
619
+
617
620
  if (appConfig.compiler) {
618
621
  compiler = makeTemplateCompiler({ ds, logger, ...appConfig.compiler })
619
622
  }
@@ -1327,6 +1330,5 @@ export function makeApp(appConfig, onTerminateOrMeta, metaOrNull) {
1327
1330
  serviceInstanceId,
1328
1331
  serviceWorkerId,
1329
1332
  signal: ac.signal,
1330
- affinity,
1331
1333
  })
1332
1334
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "27.0.2",
3
+ "version": "27.0.3",
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": "ad258cea82e41d8d196fc344fd7436675abf70a0"
90
+ "gitHead": "383b7fe1d10a8b7d80aa80ea81e7828f415d248d"
91
91
  }