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 +31 -29
- package/build/cjs/main.js.map +2 -2
- package/build/esm/main.d.ts.map +1 -1
- package/build/esm/main.js +34 -33
- package/build/esm/main.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/io-package.json +2 -2
- package/package.json +14 -14
package/build/esm/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAyjKH;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmajE"}
|
package/build/esm/main.js
CHANGED
|
@@ -18,7 +18,7 @@ import restart from './lib/restart.js';
|
|
|
18
18
|
import pidUsage from 'pidusage';
|
|
19
19
|
import deepClone from 'deep-clone';
|
|
20
20
|
import { isDeepStrictEqual, inspect } from 'node:util';
|
|
21
|
-
import { tools, EXIT_CODES, logger as toolsLogger, isLocalObjectsDbServer, isLocalStatesDbServer, NotificationHandler, getObjectsConstructor, getStatesConstructor, zipFiles, getInstancesOrderedByStartPrio } from '@iobroker/js-controller-common';
|
|
21
|
+
import { tools, EXIT_CODES, logger as toolsLogger, isLocalObjectsDbServer, isLocalStatesDbServer, NotificationHandler, getObjectsConstructor, getStatesConstructor, zipFiles, getInstancesOrderedByStartPrio, isInstalledFromNpm } from '@iobroker/js-controller-common';
|
|
22
22
|
import { SYSTEM_ADAPTER_PREFIX, SYSTEM_CONFIG_ID, SYSTEM_HOST_PREFIX, SYSTEM_REPOSITORIES_ID } from '@iobroker/js-controller-common-db/constants';
|
|
23
23
|
import { PluginHandler } from '@iobroker/plugin-base';
|
|
24
24
|
import { BlocklistManager } from './lib/blocklistManager.js';
|
|
@@ -57,7 +57,6 @@ if (os.platform() === 'win32') {
|
|
|
57
57
|
require('loadavg-windows');
|
|
58
58
|
}
|
|
59
59
|
tools.ensureDNSOrder();
|
|
60
|
-
let title = `${tools.appName}.js-controller`;
|
|
61
60
|
let Objects;
|
|
62
61
|
let States;
|
|
63
62
|
let logger;
|
|
@@ -80,12 +79,12 @@ let connectTimeout = null;
|
|
|
80
79
|
let reportInterval = null;
|
|
81
80
|
let primaryHostInterval = null;
|
|
82
81
|
let isPrimary = false;
|
|
82
|
+
/** If system reboot is required */
|
|
83
|
+
let isRebootRequired = false;
|
|
83
84
|
const PRIMARY_HOST_LOCK_TIME = 60_000;
|
|
84
85
|
const VENDOR_BOOTSTRAP_FILE = '/opt/iobroker/iob-vendor-secret.json';
|
|
85
86
|
const VENDOR_FILE = '/etc/iob-vendor.json';
|
|
86
87
|
const procs = {};
|
|
87
|
-
// TODO type is probably InstanceCommon
|
|
88
|
-
const hostAdapter = {};
|
|
89
88
|
const subscribe = {};
|
|
90
89
|
const stopTimeouts = {};
|
|
91
90
|
let states = null;
|
|
@@ -472,8 +471,8 @@ function createStates(onConnect) {
|
|
|
472
471
|
}
|
|
473
472
|
if (pluginHandler.isPluginActive(pluginName) !== state.val) {
|
|
474
473
|
if (state.val) {
|
|
475
|
-
if (!pluginHandler.
|
|
476
|
-
pluginHandler.
|
|
474
|
+
if (!pluginHandler.isPluginInstantiated(pluginName)) {
|
|
475
|
+
pluginHandler.instantiatePlugin(pluginName, pluginHandler.getPluginConfig(pluginName), controllerDir);
|
|
477
476
|
pluginHandler.setDatabaseForPlugin(pluginName, objects, states);
|
|
478
477
|
pluginHandler.initPlugin(pluginName, ioPackage);
|
|
479
478
|
}
|
|
@@ -548,15 +547,14 @@ async function initializeController() {
|
|
|
548
547
|
connected = true;
|
|
549
548
|
if (!isStopping) {
|
|
550
549
|
pluginHandler.setDatabaseForPlugins(objects, states);
|
|
551
|
-
pluginHandler.initPlugins(ioPackage
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
});
|
|
550
|
+
await pluginHandler.initPlugins(ioPackage);
|
|
551
|
+
states.subscribe(`${hostObjectPrefix}.plugins.*`);
|
|
552
|
+
// Do not start if we're still stopping the instances
|
|
553
|
+
await checkHost();
|
|
554
|
+
startMultihost(config);
|
|
555
|
+
setMeta();
|
|
556
|
+
started = true;
|
|
557
|
+
getInstances();
|
|
560
558
|
}
|
|
561
559
|
}
|
|
562
560
|
else {
|
|
@@ -640,7 +638,6 @@ function createObjects(onConnect) {
|
|
|
640
638
|
proc.config.common.host = null;
|
|
641
639
|
// @ts-expect-error it is only used in checkAndAddInstance, find a way without modifying the InstanceObject
|
|
642
640
|
proc.config.deleted = true;
|
|
643
|
-
delete hostAdapter[id];
|
|
644
641
|
logger.info(`${hostLogPrefix} object deleted ${id}`);
|
|
645
642
|
}
|
|
646
643
|
else {
|
|
@@ -660,8 +657,6 @@ function createObjects(onConnect) {
|
|
|
660
657
|
compactProcs[proc.config.common.compactGroup].instances.splice(compactProcs[proc.config.common.compactGroup].instances.indexOf(id), 1);
|
|
661
658
|
}
|
|
662
659
|
proc.config = obj;
|
|
663
|
-
hostAdapter[id] = hostAdapter[id] || {};
|
|
664
|
-
hostAdapter[id].config = obj;
|
|
665
660
|
}
|
|
666
661
|
if (proc.process || proc.config.common.mode === 'schedule') {
|
|
667
662
|
proc.restartExpected = true;
|
|
@@ -694,7 +689,6 @@ function createObjects(onConnect) {
|
|
|
694
689
|
// instance moved -> remove all notifications, new host has to take care
|
|
695
690
|
await notificationHandler.clearNotifications(null, null, id);
|
|
696
691
|
delete procs[id];
|
|
697
|
-
delete hostAdapter[id];
|
|
698
692
|
}
|
|
699
693
|
}
|
|
700
694
|
else if (installQueue.find(obj => obj.id === id)) {
|
|
@@ -721,7 +715,6 @@ function createObjects(onConnect) {
|
|
|
721
715
|
delete proc.restartTimer;
|
|
722
716
|
}
|
|
723
717
|
delete procs[id];
|
|
724
|
-
delete hostAdapter[id];
|
|
725
718
|
}
|
|
726
719
|
}
|
|
727
720
|
}
|
|
@@ -2539,7 +2532,6 @@ async function processMessage(msg) {
|
|
|
2539
2532
|
const message = msg.message.message;
|
|
2540
2533
|
const level = msg.message.level;
|
|
2541
2534
|
const extraInfo = msg.message.extraInfo;
|
|
2542
|
-
// @ts-expect-error Plugin is not well typed and SentryPlugin has no types at all currently
|
|
2543
2535
|
const sentryObj = pluginHandler.getPluginInstance('sentry')?.getSentryObject();
|
|
2544
2536
|
if (!sentryObj) {
|
|
2545
2537
|
logger.debug(`${hostLogPrefix} Do not send message "${message}" to Sentry, because it is disabled`);
|
|
@@ -2667,10 +2659,6 @@ function checkAndAddInstance(instance, ipArr) {
|
|
|
2667
2659
|
? logger.error(`${hostLogPrefix} Cannot update hostname for ${instance._id}: ${err.message}`)
|
|
2668
2660
|
: logger.info(`${hostLogPrefix} Set hostname ${hostname} for ${instance._id}`));
|
|
2669
2661
|
}
|
|
2670
|
-
hostAdapter[instance._id] = hostAdapter[instance._id] || {};
|
|
2671
|
-
if (!hostAdapter[instance._id].config) {
|
|
2672
|
-
hostAdapter[instance._id].config = deepClone(instance);
|
|
2673
|
-
}
|
|
2674
2662
|
if (!instanceRelevantForThisController(instance, ipArr)) {
|
|
2675
2663
|
return false;
|
|
2676
2664
|
}
|
|
@@ -3137,7 +3125,11 @@ async function startScheduledInstance(callback) {
|
|
|
3137
3125
|
if (proc.process) {
|
|
3138
3126
|
storePids();
|
|
3139
3127
|
const { pid } = proc.process;
|
|
3140
|
-
|
|
3128
|
+
const isNpm = isInstalledFromNpm({
|
|
3129
|
+
installedFrom: instance.common.installedFrom,
|
|
3130
|
+
adapterName: instance.common.name
|
|
3131
|
+
});
|
|
3132
|
+
logger.info(`${hostLogPrefix} instance ${instance._id} in version "${instance.common.version}"${!isNpm ? ` (non-npm: ${instance.common.installedFrom})` : ''} started with pid ${proc.process.pid}`);
|
|
3141
3133
|
proc.process.on('exit', (code, signal) => {
|
|
3142
3134
|
outputCount++;
|
|
3143
3135
|
states.setState(`${id}.alive`, { val: false, ack: true, from: hostObjectPrefix });
|
|
@@ -3642,7 +3634,11 @@ async function startInstance(id, wakeUp = false) {
|
|
|
3642
3634
|
logger.info(`${hostLogPrefix} instance ${instance._id} is handled by compact group controller pid ${proc.process.pid}`);
|
|
3643
3635
|
}
|
|
3644
3636
|
else {
|
|
3645
|
-
|
|
3637
|
+
const isNpm = isInstalledFromNpm({
|
|
3638
|
+
installedFrom: instance.common.installedFrom,
|
|
3639
|
+
adapterName: instance.common.name
|
|
3640
|
+
});
|
|
3641
|
+
logger.info(`${hostLogPrefix} instance ${instance._id} in version "${instance.common.version}"${!isNpm ? ` (non-npm: ${instance.common.installedFrom})` : ''} started with pid ${proc.process.pid}`);
|
|
3646
3642
|
}
|
|
3647
3643
|
}
|
|
3648
3644
|
};
|
|
@@ -3943,12 +3939,16 @@ async function startInstance(id, wakeUp = false) {
|
|
|
3943
3939
|
cwd: adapterDir
|
|
3944
3940
|
});
|
|
3945
3941
|
}
|
|
3946
|
-
catch (
|
|
3947
|
-
logger.info(`${hostLogPrefix} instance ${instance._id} could not be started: ${
|
|
3942
|
+
catch (e) {
|
|
3943
|
+
logger.info(`${hostLogPrefix} instance ${instance._id} could not be started: ${e.message}`);
|
|
3948
3944
|
}
|
|
3949
3945
|
if (proc.process) {
|
|
3950
3946
|
storePids();
|
|
3951
|
-
|
|
3947
|
+
const isNpm = isInstalledFromNpm({
|
|
3948
|
+
installedFrom: instance.common.installedFrom,
|
|
3949
|
+
adapterName: instance.common.name
|
|
3950
|
+
});
|
|
3951
|
+
logger.info(`${hostLogPrefix} instance ${instance._id} in version "${instance.common.version}"${!isNpm ? ` (non-npm: ${instance.common.installedFrom})` : ''} started with pid ${proc.process.pid}`);
|
|
3952
3952
|
proc.process.on('exit', (code, signal) => {
|
|
3953
3953
|
cleanAutoSubscribes(id, () => {
|
|
3954
3954
|
const proc = procs[id];
|
|
@@ -4372,6 +4372,7 @@ function stop(force, callback) {
|
|
|
4372
4372
|
* @param compactGroupId the id of the compact group
|
|
4373
4373
|
*/
|
|
4374
4374
|
export async function init(compactGroupId) {
|
|
4375
|
+
let title = `${tools.appName}.js-controller`;
|
|
4375
4376
|
if (compactGroupId) {
|
|
4376
4377
|
compactGroupController = true;
|
|
4377
4378
|
compactGroup = compactGroupId;
|
|
@@ -4863,15 +4864,15 @@ async function startUpgradeManager(options) {
|
|
|
4863
4864
|
* Checks if a system reboot is required and generates a notification if this is the case
|
|
4864
4865
|
*/
|
|
4865
4866
|
async function checkRebootRequired() {
|
|
4866
|
-
if (process.platform !== 'linux') {
|
|
4867
|
+
if (process.platform !== 'linux' || isRebootRequired) {
|
|
4867
4868
|
return;
|
|
4868
4869
|
}
|
|
4869
4870
|
/** This file exists on most linux systems if a reboot is required */
|
|
4870
4871
|
const rebootRequiredPath = '/var/run/reboot-required';
|
|
4871
4872
|
/** This file contains a list of packages which require the reboot, separated by newline */
|
|
4872
4873
|
const packagesListPath = '/var/run/reboot-required.pkgs';
|
|
4873
|
-
|
|
4874
|
-
if (!
|
|
4874
|
+
isRebootRequired = await fs.pathExists(rebootRequiredPath);
|
|
4875
|
+
if (!isRebootRequired) {
|
|
4875
4876
|
return;
|
|
4876
4877
|
}
|
|
4877
4878
|
let message = 'At least one package update requires a system reboot';
|