iobroker.js-controller 4.0.3 → 4.0.4

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 (3) hide show
  1. package/io-package.json +13 -13
  2. package/main.js +25 -13
  3. package/package.json +12 -12
package/io-package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "js-controller",
4
- "version": "4.0.3",
4
+ "version": "4.0.4",
5
5
  "platform": "Javascript/Node.js",
6
6
  "controller": true,
7
7
  "mode": "daemon",
@@ -19,6 +19,18 @@
19
19
  "zh-cn": "JS控制器"
20
20
  },
21
21
  "news": {
22
+ "4.0.4": {
23
+ "en": "Optimize database initialization and destroys\nUpdate winston-syslog to prevent errors\nAllow proper setup first upgrade from 3.3.x",
24
+ "de": "Optimieren Sie die Initialisierung und Zerstörung von Datenbanken\nAktualisieren Sie winston-syslog, um Fehler zu vermeiden\nErst-Upgrade von 3.3.x auf ordnungsgemäße Einrichtung zulassen",
25
+ "ru": "Оптимизация инициализации и уничтожения базы данных\nОбновите winston-syslog, чтобы предотвратить ошибки\nРазрешить правильную настройку первого обновления с 3.3.x",
26
+ "pt": "Otimize a inicialização do banco de dados e destrua\nAtualize o winston-syslog para evitar erros\nPermitir configuração adequada primeiro upgrade de 3.3.x",
27
+ "nl": "Optimaliseer database-initialisatie en vernietigt\nUpdate winston-syslog om fouten te voorkomen\nSta de juiste installatie toe, upgrade eerst vanaf 3.3.x",
28
+ "fr": "Optimiser l'initialisation et la destruction de la base de données\nMettre à jour winston-syslog pour éviter les erreurs\nAutoriser la configuration appropriée pour la première mise à niveau à partir de la version 3.3.x",
29
+ "it": "Ottimizza l'inizializzazione e la distruzione del database\nAggiorna winston-syslog per prevenire errori\nConsenti una corretta configurazione prima dell'aggiornamento da 3.3.x",
30
+ "es": "Optimizar la inicialización y destrucción de la base de datos.\nActualice winston-syslog para evitar errores\nPermitir la configuración adecuada primera actualización desde 3.3.x",
31
+ "pl": "Zoptymalizuj inicjowanie i niszczenie bazy danych\nZaktualizuj winston-syslog, aby zapobiec błędom\nZezwól na prawidłową konfigurację przy pierwszej aktualizacji z wersji 3.3.x",
32
+ "zh-cn": "优化数据库初始化和销毁\n更新 winston-syslog 以防止错误\n允许正确设置首先从 3.3.x 升级"
33
+ },
22
34
  "4.0.3": {
23
35
  "en": "see CHANGELOG.md",
24
36
  "de": "siehe CHANGELOG.md",
@@ -90,18 +102,6 @@
90
102
  "es": "ver CHANGELOG.md",
91
103
  "pl": "zobacz CHANGELOG.md",
92
104
  "zh-cn": "看到CHANGELOG.md"
93
- },
94
- "2.1.1": {
95
- "en": "see CHANGELOG.md",
96
- "de": "Siehe CHANGELOG.md",
97
- "ru": "см. CHANGELOG.md",
98
- "pt": "veja CHANGELOG.md",
99
- "nl": "zie CHANGELOG.md",
100
- "fr": "voir CHANGELOG.md",
101
- "it": "vedi CHANGELOG.md",
102
- "es": "ver CHANGELOG.md",
103
- "pl": "zobacz CHANGELOG.md",
104
- "zh-cn": "看到CHANGELOG.md"
105
105
  }
106
106
  },
107
107
  "desc": {
package/main.js CHANGED
@@ -333,7 +333,7 @@ function handleDisconnect() {
333
333
  }
334
334
 
335
335
  connected = false;
336
- logger.warn(hostLogPrefix + ' Slave controller detected disconnection. Stop all instances.');
336
+ logger.warn(`${hostLogPrefix} Slave controller detected disconnection. Stop all instances.`);
337
337
  if (compactGroupController) {
338
338
  stop(true);
339
339
  } else {
@@ -493,7 +493,7 @@ function createStates(onConnect) {
493
493
  }
494
494
  }
495
495
  },
496
- connected: async () => {
496
+ connected: () => {
497
497
  if (statesDisconnectTimeout) {
498
498
  clearTimeout(statesDisconnectTimeout);
499
499
  statesDisconnectTimeout = null;
@@ -502,16 +502,6 @@ function createStates(onConnect) {
502
502
  if (!compactGroupController) {
503
503
  states.clearAllLogs && states.clearAllLogs();
504
504
  deleteAllZipPackages();
505
- // subscribe to primary host expiration
506
- try {
507
- await objects.subscribePrimaryHost();
508
- } catch (e) {
509
- logger.error(`${hostLogPrefix} Cannot subscribe to primary host expiration: ${e.message}`);
510
- }
511
- primaryHostInterval = setInterval(checkPrimaryHost, PRIMARY_HOST_LOCK_TIME / 2);
512
-
513
- // first execution now
514
- checkPrimaryHost();
515
505
  }
516
506
  initMessageQueue();
517
507
  startAliveInterval();
@@ -599,13 +589,27 @@ function createObjects(onConnect) {
599
589
  controller: true,
600
590
  logger: logger,
601
591
  hostname: hostname,
602
- connected: () => {
592
+ connected: async () => {
603
593
  // stop disconnect timeout
604
594
  if (objectsDisconnectTimeout) {
605
595
  clearTimeout(objectsDisconnectTimeout);
606
596
  objectsDisconnectTimeout = null;
607
597
  }
608
598
 
599
+ // subscribe to primary host expiration
600
+ try {
601
+ await objects.subscribePrimaryHost();
602
+ } catch (e) {
603
+ logger.error(`${hostLogPrefix} Cannot subscribe to primary host expiration: ${e.message}`);
604
+ }
605
+
606
+ if (!primaryHostInterval && !compactGroupController) {
607
+ primaryHostInterval = setInterval(checkPrimaryHost, PRIMARY_HOST_LOCK_TIME / 2);
608
+ }
609
+
610
+ // first execution now
611
+ checkPrimaryHost();
612
+
609
613
  initializeController();
610
614
  onConnect && onConnect();
611
615
  },
@@ -613,6 +617,8 @@ function createObjects(onConnect) {
613
617
  if (restartTimeout) {
614
618
  return;
615
619
  }
620
+ // on reconnection this will be determiend anew
621
+ isPrimary = false;
616
622
  objectsDisconnectTimeout && clearTimeout(objectsDisconnectTimeout);
617
623
  objectsDisconnectTimeout = setTimeout(() => {
618
624
  objectsDisconnectTimeout = null;
@@ -860,6 +866,7 @@ function createObjects(onConnect) {
860
866
  },
861
867
  primaryHostLost: () => {
862
868
  if (!isStopping) {
869
+ isPrimary = false;
863
870
  logger.info('The primary host is no longer active. Checking responsibilities.');
864
871
  checkPrimaryHost();
865
872
  }
@@ -893,6 +900,11 @@ function startAliveInterval() {
893
900
  * @return {Promise<void>}
894
901
  */
895
902
  async function checkPrimaryHost() {
903
+ // we cannot interact with db now because currently reconnecting
904
+ if (objectsDisconnectTimeout || compactGroupController) {
905
+ return;
906
+ }
907
+
896
908
  // let our host value live PRIMARY_HOST_LOCK_TIME seconds, while it should be renewed lock time / 2
897
909
  try {
898
910
  if (!isPrimary) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.js-controller",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "engines": {
5
5
  "node": ">=12.0.0"
6
6
  },
@@ -17,16 +17,16 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@alcalzone/esbuild-register": "^2.5.1-1",
20
- "@iobroker/db-objects-file": "4.0.3",
21
- "@iobroker/db-objects-jsonl": "4.0.3",
22
- "@iobroker/db-objects-redis": "4.0.3",
23
- "@iobroker/db-states-file": "4.0.3",
24
- "@iobroker/db-states-jsonl": "4.0.3",
25
- "@iobroker/db-states-redis": "4.0.3",
26
- "@iobroker/js-controller-adapter": "4.0.3",
27
- "@iobroker/js-controller-cli": "4.0.3",
28
- "@iobroker/js-controller-common": "4.0.3",
29
- "@iobroker/js-controller-common-db": "4.0.3",
20
+ "@iobroker/db-objects-file": "4.0.4",
21
+ "@iobroker/db-objects-jsonl": "4.0.4",
22
+ "@iobroker/db-objects-redis": "4.0.4",
23
+ "@iobroker/db-states-file": "4.0.4",
24
+ "@iobroker/db-states-jsonl": "4.0.4",
25
+ "@iobroker/db-states-redis": "4.0.4",
26
+ "@iobroker/js-controller-adapter": "4.0.4",
27
+ "@iobroker/js-controller-cli": "4.0.4",
28
+ "@iobroker/js-controller-common": "4.0.4",
29
+ "@iobroker/js-controller-common-db": "4.0.4",
30
30
  "@iobroker/plugin-base": "~1.2.1",
31
31
  "@iobroker/plugin-sentry": "~1.1.10",
32
32
  "axios": "^0.24.0",
@@ -113,5 +113,5 @@
113
113
  "iobroker.js",
114
114
  "main.js"
115
115
  ],
116
- "gitHead": "79a76a082db91399d0e432ef02bf2981a6739107"
116
+ "gitHead": "184f8340136fe668fb4d64d572ebeecb7b06b6e7"
117
117
  }