iobroker.js-controller 6.0.6 → 6.0.7

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/build/cjs/main.js CHANGED
@@ -69,7 +69,6 @@ if (import_node_os.default.platform() === "win32") {
69
69
  require2("loadavg-windows");
70
70
  }
71
71
  import_js_controller_common.tools.ensureDNSOrder();
72
- let title = `${import_js_controller_common.tools.appName}.js-controller`;
73
72
  let Objects;
74
73
  let States;
75
74
  let logger;
@@ -92,11 +91,11 @@ let connectTimeout = null;
92
91
  let reportInterval = null;
93
92
  let primaryHostInterval = null;
94
93
  let isPrimary = false;
94
+ let isRebootRequired = false;
95
95
  const PRIMARY_HOST_LOCK_TIME = 6e4;
96
96
  const VENDOR_BOOTSTRAP_FILE = "/opt/iobroker/iob-vendor-secret.json";
97
97
  const VENDOR_FILE = "/etc/iob-vendor.json";
98
98
  const procs = {};
99
- const hostAdapter = {};
100
99
  const subscribe = {};
101
100
  const stopTimeouts = {};
102
101
  let states = null;
@@ -407,8 +406,8 @@ function createStates(onConnect) {
407
406
  }
408
407
  if (pluginHandler.isPluginActive(pluginName) !== state.val) {
409
408
  if (state.val) {
410
- if (!pluginHandler.isPluginInstanciated(pluginName)) {
411
- pluginHandler.instanciatePlugin(pluginName, pluginHandler.getPluginConfig(pluginName), controllerDir);
409
+ if (!pluginHandler.isPluginInstantiated(pluginName)) {
410
+ pluginHandler.instantiatePlugin(pluginName, pluginHandler.getPluginConfig(pluginName), controllerDir);
412
411
  pluginHandler.setDatabaseForPlugin(pluginName, objects, states);
413
412
  pluginHandler.initPlugin(pluginName, ioPackage);
414
413
  }
@@ -475,14 +474,13 @@ async function initializeController() {
475
474
  connected = true;
476
475
  if (!isStopping) {
477
476
  pluginHandler.setDatabaseForPlugins(objects, states);
478
- pluginHandler.initPlugins(ioPackage, async () => {
479
- states.subscribe(`${hostObjectPrefix}.plugins.*`);
480
- await checkHost();
481
- startMultihost(config);
482
- setMeta();
483
- started = true;
484
- getInstances();
485
- });
477
+ await pluginHandler.initPlugins(ioPackage);
478
+ states.subscribe(`${hostObjectPrefix}.plugins.*`);
479
+ await checkHost();
480
+ startMultihost(config);
481
+ setMeta();
482
+ started = true;
483
+ getInstances();
486
484
  }
487
485
  } else {
488
486
  connected = true;
@@ -545,7 +543,6 @@ function createObjects(onConnect) {
545
543
  proc.config.common.enabled = false;
546
544
  proc.config.common.host = null;
547
545
  proc.config.deleted = true;
548
- delete hostAdapter[id];
549
546
  logger.info(`${hostLogPrefix} object deleted ${id}`);
550
547
  } else {
551
548
  if (proc.config.common.enabled && !obj.common.enabled) {
@@ -559,8 +556,6 @@ function createObjects(onConnect) {
559
556
  compactProcs[proc.config.common.compactGroup].instances.splice(compactProcs[proc.config.common.compactGroup].instances.indexOf(id), 1);
560
557
  }
561
558
  proc.config = obj;
562
- hostAdapter[id] = hostAdapter[id] || {};
563
- hostAdapter[id].config = obj;
564
559
  }
565
560
  if (proc.process || proc.config.common.mode === "schedule") {
566
561
  proc.restartExpected = true;
@@ -587,7 +582,6 @@ function createObjects(onConnect) {
587
582
  }
588
583
  await notificationHandler.clearNotifications(null, null, id);
589
584
  delete procs[id];
590
- delete hostAdapter[id];
591
585
  }
592
586
  } else if (installQueue.find((obj2) => obj2.id === id)) {
593
587
  logger.debug(`${hostLogPrefix} ignore object change because the adapter is still in installation/rebuild queue`);
@@ -606,7 +600,6 @@ function createObjects(onConnect) {
606
600
  delete proc.restartTimer;
607
601
  }
608
602
  delete procs[id];
609
- delete hostAdapter[id];
610
603
  }
611
604
  }
612
605
  } else if (obj?.common) {
@@ -2196,10 +2189,6 @@ function checkAndAddInstance(instance, ipArr) {
2196
2189
  instance.common.host = hostname;
2197
2190
  objects.setObject(instance._id, instance, (err) => err ? logger.error(`${hostLogPrefix} Cannot update hostname for ${instance._id}: ${err.message}`) : logger.info(`${hostLogPrefix} Set hostname ${hostname} for ${instance._id}`));
2198
2191
  }
2199
- hostAdapter[instance._id] = hostAdapter[instance._id] || {};
2200
- if (!hostAdapter[instance._id].config) {
2201
- hostAdapter[instance._id].config = (0, import_deep_clone.default)(instance);
2202
- }
2203
2192
  if (!instanceRelevantForThisController(instance, ipArr)) {
2204
2193
  return false;
2205
2194
  }
@@ -2583,7 +2572,11 @@ async function startScheduledInstance(callback) {
2583
2572
  if (proc.process) {
2584
2573
  storePids();
2585
2574
  const { pid } = proc.process;
2586
- logger.info(`${hostLogPrefix} instance ${instance._id} started with pid ${proc.process.pid}`);
2575
+ const isNpm = (0, import_js_controller_common.isInstalledFromNpm)({
2576
+ installedFrom: instance.common.installedFrom,
2577
+ adapterName: instance.common.name
2578
+ });
2579
+ logger.info(`${hostLogPrefix} instance ${instance._id} in version "${instance.common.version}"${!isNpm ? ` (non-npm: ${instance.common.installedFrom})` : ""} started with pid ${proc.process.pid}`);
2587
2580
  proc.process.on("exit", (code, signal) => {
2588
2581
  outputCount++;
2589
2582
  states.setState(`${id}.alive`, { val: false, ack: true, from: hostObjectPrefix });
@@ -2981,7 +2974,11 @@ async function startInstance(id, wakeUp = false) {
2981
2974
  } else if (proc2.startedAsCompactGroup) {
2982
2975
  logger.info(`${hostLogPrefix} instance ${instance._id} is handled by compact group controller pid ${proc2.process.pid}`);
2983
2976
  } else {
2984
- logger.info(`${hostLogPrefix} instance ${instance._id} started with pid ${proc2.process.pid}`);
2977
+ const isNpm = (0, import_js_controller_common.isInstalledFromNpm)({
2978
+ installedFrom: instance.common.installedFrom,
2979
+ adapterName: instance.common.name
2980
+ });
2981
+ logger.info(`${hostLogPrefix} instance ${instance._id} in version "${instance.common.version}"${!isNpm ? ` (non-npm: ${instance.common.installedFrom})` : ""} started with pid ${proc2.process.pid}`);
2985
2982
  }
2986
2983
  }
2987
2984
  };
@@ -3227,12 +3224,16 @@ async function startInstance(id, wakeUp = false) {
3227
3224
  windowsHide: true,
3228
3225
  cwd: adapterDir
3229
3226
  });
3230
- } catch (err) {
3231
- logger.info(`${hostLogPrefix} instance ${instance._id} could not be started: ${err}`);
3227
+ } catch (e) {
3228
+ logger.info(`${hostLogPrefix} instance ${instance._id} could not be started: ${e.message}`);
3232
3229
  }
3233
3230
  if (proc.process) {
3234
3231
  storePids();
3235
- logger.info(`${hostLogPrefix} instance ${instance._id} started with pid ${proc.process.pid}`);
3232
+ const isNpm = (0, import_js_controller_common.isInstalledFromNpm)({
3233
+ installedFrom: instance.common.installedFrom,
3234
+ adapterName: instance.common.name
3235
+ });
3236
+ logger.info(`${hostLogPrefix} instance ${instance._id} in version "${instance.common.version}"${!isNpm ? ` (non-npm: ${instance.common.installedFrom})` : ""} started with pid ${proc.process.pid}`);
3236
3237
  proc.process.on("exit", (code, signal) => {
3237
3238
  cleanAutoSubscribes(id, () => {
3238
3239
  const proc2 = procs[id];
@@ -3590,6 +3591,7 @@ function stop(force, callback) {
3590
3591
  });
3591
3592
  }
3592
3593
  async function init(compactGroupId) {
3594
+ let title = `${import_js_controller_common.tools.appName}.js-controller`;
3593
3595
  if (compactGroupId) {
3594
3596
  compactGroupController = true;
3595
3597
  compactGroup = compactGroupId;
@@ -3980,13 +3982,13 @@ async function startUpgradeManager(options) {
3980
3982
  upgradeProcess.unref();
3981
3983
  }
3982
3984
  async function checkRebootRequired() {
3983
- if (process.platform !== "linux") {
3985
+ if (process.platform !== "linux" || isRebootRequired) {
3984
3986
  return;
3985
3987
  }
3986
3988
  const rebootRequiredPath = "/var/run/reboot-required";
3987
3989
  const packagesListPath = "/var/run/reboot-required.pkgs";
3988
- const rebootRequired = await import_fs_extra.default.pathExists(rebootRequiredPath);
3989
- if (!rebootRequired) {
3990
+ isRebootRequired = await import_fs_extra.default.pathExists(rebootRequiredPath);
3991
+ if (!isRebootRequired) {
3990
3992
  return;
3991
3993
  }
3992
3994
  let message = "At least one package update requires a system reboot";