incyclist-services 1.0.69 → 1.0.70
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/lib/devices/ride/service.js +10 -4
- package/package.json +2 -2
|
@@ -476,6 +476,7 @@ class DeviceRideService extends events_1.default {
|
|
|
476
476
|
const check = () => {
|
|
477
477
|
const tsNow = Date.now();
|
|
478
478
|
const isPaused = ai.adapter.isPaused();
|
|
479
|
+
const prevStatus = ai.dataStatus;
|
|
479
480
|
if (isPaused || !ai.tsLastData) {
|
|
480
481
|
ai.tsLastData = tsNow;
|
|
481
482
|
ai.dataStatus = 'green';
|
|
@@ -491,16 +492,16 @@ class DeviceRideService extends events_1.default {
|
|
|
491
492
|
if (ai.isHealthy && (isAmber || isRed)) {
|
|
492
493
|
ai.isHealthy = false;
|
|
493
494
|
this.logEvent({ message: 'device unhealthy', device: ai.adapter.getUniqueName(), udid: ai.udid });
|
|
494
|
-
const { enabledCapabilities } = this.getEnabledCapabilities(ai);
|
|
495
|
-
this.emit('unhealthy', ai.udid, ai.dataStatus, enabledCapabilities);
|
|
496
495
|
console.log('~~~~ health check: prepare reconnect');
|
|
497
496
|
this.prepareReconnect(ai);
|
|
498
497
|
}
|
|
499
498
|
else if (!ai.isHealthy && !isAmber && !isRed) {
|
|
500
|
-
const { enabledCapabilities } = this.getEnabledCapabilities(ai);
|
|
501
499
|
ai.isHealthy = true;
|
|
502
500
|
this.logEvent({ message: 'device healthy', device: ai.adapter.getUniqueName(), udid: ai.udid });
|
|
503
|
-
|
|
501
|
+
}
|
|
502
|
+
if (ai.dataStatus !== prevStatus) {
|
|
503
|
+
const { enabledCapabilities } = this.getEnabledCapabilities(ai);
|
|
504
|
+
this.emit('health', ai.udid, ai.dataStatus, enabledCapabilities);
|
|
504
505
|
}
|
|
505
506
|
};
|
|
506
507
|
ai.ivToCheck = (0, timers_1.setInterval)(check, 1000);
|
|
@@ -542,6 +543,7 @@ class DeviceRideService extends events_1.default {
|
|
|
542
543
|
this.once('stop-ride', () => { stopRequested = true; });
|
|
543
544
|
const i = incyclist_devices_1.InterfaceFactory.create(ifName);
|
|
544
545
|
try {
|
|
546
|
+
console.log('~~~~ health check: stop Adapters', ifName);
|
|
545
547
|
const promisesStop = [];
|
|
546
548
|
adapters.map(ai => {
|
|
547
549
|
if (ai.isRestarting) {
|
|
@@ -556,11 +558,13 @@ class DeviceRideService extends events_1.default {
|
|
|
556
558
|
if (promisesStop.length > 0) {
|
|
557
559
|
yield Promise.allSettled(promisesStop);
|
|
558
560
|
}
|
|
561
|
+
console.log('~~~~ health check: reconnect interface', ifName);
|
|
559
562
|
if (!stopRequested) {
|
|
560
563
|
yield i.disconnect();
|
|
561
564
|
yield (0, sleep_1.sleep)(1000);
|
|
562
565
|
yield i.connect();
|
|
563
566
|
}
|
|
567
|
+
console.log('~~~~ health check: start adapters', ifName);
|
|
564
568
|
if (!stopRequested) {
|
|
565
569
|
const promisesStart = [];
|
|
566
570
|
adapters.map(ai => { promisesStart.push(ai.adapter.start()); });
|
|
@@ -571,12 +575,14 @@ class DeviceRideService extends events_1.default {
|
|
|
571
575
|
}
|
|
572
576
|
catch (err) {
|
|
573
577
|
this.logger.logEvent({ message: 'restart interface failed', interface: ifName, reason: err.message });
|
|
578
|
+
console.log('~~~~ health check: restart interface error', ifName, err);
|
|
574
579
|
}
|
|
575
580
|
adapters.map(ai => {
|
|
576
581
|
if (ai.adapter.isStarted()) {
|
|
577
582
|
ai.tsLastData = Date.now();
|
|
578
583
|
}
|
|
579
584
|
else {
|
|
585
|
+
console.log('~~~~ health check: adapter still not healthy', ifName, ai.udid);
|
|
580
586
|
ai.isRestarting = false;
|
|
581
587
|
this.prepareReconnect(ai);
|
|
582
588
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-services",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.70",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"gd-eventlog": "^0.1.26"
|
|
6
6
|
},
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"axios": "^1.6.1",
|
|
42
|
-
"incyclist-devices": "^2.1.
|
|
42
|
+
"incyclist-devices": "^2.1.29",
|
|
43
43
|
"uuid": "^9.0.0",
|
|
44
44
|
"xml2js": "^0.6.2"
|
|
45
45
|
}
|