@iobroker/js-controller-adapter 6.0.7 → 6.0.8
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/lib/adapter/adapter.js +187 -186
- package/build/cjs/lib/adapter/adapter.js.map +2 -2
- package/build/esm/lib/adapter/adapter.d.ts.map +1 -1
- package/build/esm/lib/adapter/adapter.js +235 -234
- package/build/esm/lib/adapter/adapter.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +12 -11
|
@@ -8288,8 +8288,8 @@ export class AdapterClass extends EventEmitter {
|
|
|
8288
8288
|
}
|
|
8289
8289
|
if (this.pluginHandler.isPluginActive(pluginName) !== state.val) {
|
|
8290
8290
|
if (state.val) {
|
|
8291
|
-
if (!this.pluginHandler.
|
|
8292
|
-
this.pluginHandler.
|
|
8291
|
+
if (!this.pluginHandler.isPluginInstanciated(pluginName)) {
|
|
8292
|
+
this.pluginHandler.instanciatePlugin(pluginName, this.pluginHandler.getPluginConfig(pluginName) || {}, thisDir);
|
|
8293
8293
|
this.pluginHandler.setDatabaseForPlugin(pluginName, this.#objects, this.#states);
|
|
8294
8294
|
this.pluginHandler.initPlugin(pluginName, this.adapterConfig || {});
|
|
8295
8295
|
}
|
|
@@ -8677,264 +8677,265 @@ export class AdapterClass extends EventEmitter {
|
|
|
8677
8677
|
return;
|
|
8678
8678
|
}
|
|
8679
8679
|
this.pluginHandler.setDatabaseForPlugins(this.#objects, this.#states);
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8680
|
+
this.pluginHandler.initPlugins(adapterConfig || {}, async () => {
|
|
8681
|
+
if (!this.#states || !this.#objects || this.terminated) {
|
|
8682
|
+
// if adapterState was destroyed,we should not continue
|
|
8683
|
+
return;
|
|
8684
|
+
}
|
|
8685
|
+
this.#states.subscribe(`system.adapter.${this.namespace}.plugins.*`);
|
|
8686
|
+
if (this._options.instance === undefined) {
|
|
8687
|
+
if (!adapterConfig || !('common' in adapterConfig) || !adapterConfig.common.enabled) {
|
|
8688
|
+
if (adapterConfig && 'common' in adapterConfig && adapterConfig.common.enabled !== undefined) {
|
|
8689
|
+
!this._config.isInstall && this._logger.error(`${this.namespaceLog} adapter disabled`);
|
|
8690
|
+
}
|
|
8691
|
+
else {
|
|
8692
|
+
!this._config.isInstall &&
|
|
8693
|
+
this._logger.error(`${this.namespaceLog} no config found for adapter`);
|
|
8694
|
+
}
|
|
8695
|
+
if (!this._config.isInstall && (!process.argv || !this._config.forceIfDisabled)) {
|
|
8696
|
+
const id = `system.adapter.${this.namespace}`;
|
|
8697
|
+
this.outputCount += 2;
|
|
8698
|
+
this.#states.setState(`${id}.alive`, { val: true, ack: true, expire: 30, from: id });
|
|
8699
|
+
let done = false;
|
|
8700
|
+
this.#states.setState(`${id}.connected`, {
|
|
8701
|
+
val: true,
|
|
8702
|
+
ack: true,
|
|
8703
|
+
expire: 30,
|
|
8704
|
+
from: id
|
|
8705
|
+
}, () => {
|
|
8706
|
+
if (!done) {
|
|
8707
|
+
done = true;
|
|
8708
|
+
this.terminate(EXIT_CODES.NO_ADAPTER_CONFIG_FOUND);
|
|
8709
|
+
}
|
|
8710
|
+
});
|
|
8711
|
+
setTimeout(() => {
|
|
8712
|
+
if (!done) {
|
|
8713
|
+
done = true;
|
|
8714
|
+
this.terminate(EXIT_CODES.NO_ADAPTER_CONFIG_FOUND);
|
|
8715
|
+
}
|
|
8716
|
+
}, 1_000);
|
|
8717
|
+
return;
|
|
8718
|
+
}
|
|
8719
|
+
}
|
|
8720
|
+
if (!this._config.isInstall && (!adapterConfig || !('_id' in adapterConfig))) {
|
|
8721
|
+
this._logger.error(`${this.namespaceLog} invalid config: no _id found`);
|
|
8722
|
+
this.terminate(EXIT_CODES.INVALID_ADAPTER_ID);
|
|
8723
|
+
return;
|
|
8724
|
+
}
|
|
8725
|
+
let name;
|
|
8726
|
+
let instance;
|
|
8727
|
+
if (!this._config.isInstall) {
|
|
8728
|
+
// @ts-expect-error
|
|
8729
|
+
const tmp = adapterConfig._id.match(/^system\.adapter\.([a-zA-Z0-9-_]+)\.([0-9]+)$/);
|
|
8730
|
+
if (!tmp) {
|
|
8731
|
+
this._logger.error(`${this.namespaceLog} invalid config`);
|
|
8732
|
+
this.terminate(EXIT_CODES.INVALID_ADAPTER_ID);
|
|
8733
|
+
return;
|
|
8734
|
+
}
|
|
8735
|
+
name = tmp[1];
|
|
8736
|
+
instance = parseInt(tmp[2]) || 0;
|
|
8690
8737
|
}
|
|
8691
8738
|
else {
|
|
8692
|
-
|
|
8739
|
+
name = this.name;
|
|
8740
|
+
instance = 0;
|
|
8741
|
+
adapterConfig = adapterConfig || {
|
|
8742
|
+
// @ts-expect-error protectedNative exists on instance objects
|
|
8743
|
+
common: { mode: 'once', name: name, protectedNative: [] },
|
|
8744
|
+
native: {}
|
|
8745
|
+
};
|
|
8693
8746
|
}
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
from: id
|
|
8704
|
-
}, () => {
|
|
8705
|
-
if (!done) {
|
|
8706
|
-
done = true;
|
|
8707
|
-
this.terminate(EXIT_CODES.NO_ADAPTER_CONFIG_FOUND);
|
|
8708
|
-
}
|
|
8709
|
-
});
|
|
8710
|
-
setTimeout(() => {
|
|
8711
|
-
if (!done) {
|
|
8712
|
-
done = true;
|
|
8713
|
-
this.terminate(EXIT_CODES.NO_ADAPTER_CONFIG_FOUND);
|
|
8747
|
+
// @ts-expect-error
|
|
8748
|
+
if (adapterConfig.common.loglevel && !this.overwriteLogLevel) {
|
|
8749
|
+
// set configured in DB log level
|
|
8750
|
+
for (const trans of Object.values(this._logger.transports)) {
|
|
8751
|
+
// set the loglevel on transport only if no loglevel was pinned in log config
|
|
8752
|
+
// @ts-expect-error it is our own modification
|
|
8753
|
+
if (!trans._defaultConfigLoglevel) {
|
|
8754
|
+
// @ts-expect-error
|
|
8755
|
+
trans.level = adapterConfig.common.loglevel;
|
|
8714
8756
|
}
|
|
8715
|
-
}
|
|
8716
|
-
|
|
8757
|
+
}
|
|
8758
|
+
// @ts-expect-error
|
|
8759
|
+
this._config.log.level = adapterConfig.common.loglevel;
|
|
8717
8760
|
}
|
|
8718
|
-
}
|
|
8719
|
-
if (!this._config.isInstall && (!adapterConfig || !('_id' in adapterConfig))) {
|
|
8720
|
-
this._logger.error(`${this.namespaceLog} invalid config: no _id found`);
|
|
8721
|
-
this.terminate(EXIT_CODES.INVALID_ADAPTER_ID);
|
|
8722
|
-
return;
|
|
8723
|
-
}
|
|
8724
|
-
let name;
|
|
8725
|
-
let instance;
|
|
8726
|
-
if (!this._config.isInstall) {
|
|
8727
8761
|
// @ts-expect-error
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8762
|
+
this.name = adapterConfig.common.name;
|
|
8763
|
+
this.instance = instance;
|
|
8764
|
+
this.namespace = `${name}.${instance}`;
|
|
8765
|
+
this.namespaceLog = this.namespace + (this.startedInCompactMode ? ' (COMPACT)' : ` (${process.pid})`);
|
|
8766
|
+
if (!this.startedInCompactMode) {
|
|
8767
|
+
process.title = `io.${this.namespace}`;
|
|
8768
|
+
}
|
|
8769
|
+
// @ts-expect-error
|
|
8770
|
+
this.config = adapterConfig.native;
|
|
8771
|
+
// @ts-expect-error
|
|
8772
|
+
this.host = adapterConfig.common.host;
|
|
8773
|
+
// @ts-expect-error
|
|
8774
|
+
this.common = adapterConfig.common;
|
|
8775
|
+
if (
|
|
8776
|
+
// @ts-expect-error
|
|
8777
|
+
adapterConfig.common.mode === 'schedule' ||
|
|
8778
|
+
// @ts-expect-error
|
|
8779
|
+
adapterConfig.common.mode === 'once') {
|
|
8780
|
+
this.stop = params => this._stop({ ...params, isPause: true });
|
|
8781
|
+
}
|
|
8782
|
+
else if (this.startedInCompactMode) {
|
|
8783
|
+
this.stop = params => this._stop({ ...params, isPause: false });
|
|
8784
|
+
this.kill = this.stop;
|
|
8785
|
+
}
|
|
8786
|
+
else {
|
|
8787
|
+
this.stop = params => this._stop({ ...params, isPause: false });
|
|
8788
|
+
}
|
|
8789
|
+
// Monitor logging state
|
|
8790
|
+
this.#states.subscribe(`${SYSTEM_ADAPTER_PREFIX}*.logging`);
|
|
8791
|
+
if (typeof this._options.message === 'function' &&
|
|
8792
|
+
// @ts-expect-error, we should infer correctly that this is an InstanceObject in this case
|
|
8793
|
+
!isMessageboxSupported(adapterConfig.common)) {
|
|
8794
|
+
this._logger.error(`${this.namespaceLog} : message handler implemented, but messagebox not enabled. Define common.messagebox in io-package.json for adapter or delete message handler.`);
|
|
8795
|
+
// @ts-expect-error we should infer adapterConfig correctly
|
|
8796
|
+
}
|
|
8797
|
+
else if (isMessageboxSupported(adapterConfig.common)) {
|
|
8798
|
+
this.mboxSubscribed = true;
|
|
8799
|
+
this.#states.subscribeMessage(`system.adapter.${this.namespace}`);
|
|
8733
8800
|
}
|
|
8734
|
-
name = tmp[1];
|
|
8735
|
-
instance = parseInt(tmp[2]) || 0;
|
|
8736
8801
|
}
|
|
8737
8802
|
else {
|
|
8738
|
-
name = this.name;
|
|
8739
|
-
instance = 0;
|
|
8740
|
-
adapterConfig = adapterConfig || {
|
|
8741
|
-
// @ts-expect-error protectedNative exists on instance objects
|
|
8742
|
-
common: { mode: 'once', name: name, protectedNative: [] },
|
|
8743
|
-
native: {}
|
|
8744
|
-
};
|
|
8745
|
-
}
|
|
8746
|
-
// @ts-expect-error
|
|
8747
|
-
if (adapterConfig.common.loglevel && !this.overwriteLogLevel) {
|
|
8748
|
-
// set configured in DB log level
|
|
8749
|
-
for (const trans of Object.values(this._logger.transports)) {
|
|
8750
|
-
// set the loglevel on transport only if no loglevel was pinned in log config
|
|
8751
|
-
// @ts-expect-error it is our own modification
|
|
8752
|
-
if (!trans._defaultConfigLoglevel) {
|
|
8753
|
-
// @ts-expect-error
|
|
8754
|
-
trans.level = adapterConfig.common.loglevel;
|
|
8755
|
-
}
|
|
8756
|
-
}
|
|
8757
8803
|
// @ts-expect-error
|
|
8758
|
-
this.
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
this.
|
|
8770
|
-
|
|
8771
|
-
this.
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
if (
|
|
8804
|
+
this.name = adapterConfig.name || this.name;
|
|
8805
|
+
// @ts-expect-error
|
|
8806
|
+
this.instance = adapterConfig.instance || 0;
|
|
8807
|
+
this.namespace = `${this.name}.${this.instance}`;
|
|
8808
|
+
this.namespaceLog = this.namespace + (this.startedInCompactMode ? ' (COMPACT)' : ` (${process.pid})`);
|
|
8809
|
+
// @ts-expect-error
|
|
8810
|
+
this.config = adapterConfig.native || {};
|
|
8811
|
+
// @ts-expect-error
|
|
8812
|
+
this.common = adapterConfig.common || {};
|
|
8813
|
+
this.host = this.common?.host || tools.getHostName() || os.hostname();
|
|
8814
|
+
}
|
|
8815
|
+
this.adapterConfig = adapterConfig;
|
|
8816
|
+
this._utils = new Validator(this.#objects, this.#states, this.namespaceLog, this._logger, this.namespace, this._namespaceRegExp);
|
|
8817
|
+
this.log = new Log(this.namespaceLog, this._config.log.level, this._logger);
|
|
8818
|
+
await this._createInstancesObjects(adapterConfig);
|
|
8819
|
+
// auto oObjects
|
|
8820
|
+
if (this._options.objects) {
|
|
8821
|
+
this.oObjects = await this.getAdapterObjectsAsync();
|
|
8822
|
+
await this.subscribeObjectsAsync('*');
|
|
8823
|
+
}
|
|
8824
|
+
// initialize the system secret
|
|
8825
|
+
await this.getSystemSecret();
|
|
8826
|
+
// Decrypt all attributes of encryptedNative
|
|
8827
|
+
const promises = [];
|
|
8775
8828
|
// @ts-expect-error
|
|
8776
|
-
adapterConfig.
|
|
8829
|
+
if (Array.isArray(adapterConfig.encryptedNative)) {
|
|
8777
8830
|
// @ts-expect-error
|
|
8778
|
-
adapterConfig.
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8831
|
+
for (const attr of adapterConfig.encryptedNative) {
|
|
8832
|
+
// we can only decrypt strings
|
|
8833
|
+
// @ts-expect-error
|
|
8834
|
+
if (typeof this.config[attr] === 'string') {
|
|
8835
|
+
promises.push(this.getEncryptedConfig(attr)
|
|
8836
|
+
// @ts-expect-error
|
|
8837
|
+
.then(decryptedValue => (this.config[attr] = decryptedValue))
|
|
8838
|
+
.catch(e => this._logger.error(`${this.namespaceLog} Can not decrypt attribute ${attr}: ${e.message}`)));
|
|
8839
|
+
}
|
|
8840
|
+
}
|
|
8784
8841
|
}
|
|
8785
8842
|
else {
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
if (typeof this._options.message === 'function' &&
|
|
8791
|
-
// @ts-expect-error, we should infer correctly that this is an InstanceObject in this case
|
|
8792
|
-
!isMessageboxSupported(adapterConfig.common)) {
|
|
8793
|
-
this._logger.error(`${this.namespaceLog} : message handler implemented, but messagebox not enabled. Define common.messagebox in io-package.json for adapter or delete message handler.`);
|
|
8794
|
-
// @ts-expect-error we should infer adapterConfig correctly
|
|
8795
|
-
}
|
|
8796
|
-
else if (isMessageboxSupported(adapterConfig.common)) {
|
|
8797
|
-
this.mboxSubscribed = true;
|
|
8798
|
-
this.#states.subscribeMessage(`system.adapter.${this.namespace}`);
|
|
8799
|
-
}
|
|
8800
|
-
}
|
|
8801
|
-
else {
|
|
8802
|
-
// @ts-expect-error
|
|
8803
|
-
this.name = adapterConfig.name || this.name;
|
|
8804
|
-
// @ts-expect-error
|
|
8805
|
-
this.instance = adapterConfig.instance || 0;
|
|
8806
|
-
this.namespace = `${this.name}.${this.instance}`;
|
|
8807
|
-
this.namespaceLog = this.namespace + (this.startedInCompactMode ? ' (COMPACT)' : ` (${process.pid})`);
|
|
8808
|
-
// @ts-expect-error
|
|
8809
|
-
this.config = adapterConfig.native || {};
|
|
8810
|
-
// @ts-expect-error
|
|
8811
|
-
this.common = adapterConfig.common || {};
|
|
8812
|
-
this.host = this.common?.host || tools.getHostName() || os.hostname();
|
|
8813
|
-
}
|
|
8814
|
-
this.adapterConfig = adapterConfig;
|
|
8815
|
-
this._utils = new Validator(this.#objects, this.#states, this.namespaceLog, this._logger, this.namespace, this._namespaceRegExp);
|
|
8816
|
-
this.log = new Log(this.namespaceLog, this._config.log.level, this._logger);
|
|
8817
|
-
await this._createInstancesObjects(adapterConfig);
|
|
8818
|
-
// auto oObjects
|
|
8819
|
-
if (this._options.objects) {
|
|
8820
|
-
this.oObjects = await this.getAdapterObjectsAsync();
|
|
8821
|
-
await this.subscribeObjectsAsync('*');
|
|
8822
|
-
}
|
|
8823
|
-
// initialize the system secret
|
|
8824
|
-
await this.getSystemSecret();
|
|
8825
|
-
// Decrypt all attributes of encryptedNative
|
|
8826
|
-
const promises = [];
|
|
8827
|
-
// @ts-expect-error
|
|
8828
|
-
if (Array.isArray(adapterConfig.encryptedNative)) {
|
|
8829
|
-
// @ts-expect-error
|
|
8830
|
-
for (const attr of adapterConfig.encryptedNative) {
|
|
8831
|
-
// we can only decrypt strings
|
|
8832
|
-
// @ts-expect-error
|
|
8833
|
-
if (typeof this.config[attr] === 'string') {
|
|
8834
|
-
promises.push(this.getEncryptedConfig(attr)
|
|
8835
|
-
// @ts-expect-error
|
|
8836
|
-
.then(decryptedValue => (this.config[attr] = decryptedValue))
|
|
8837
|
-
.catch(e => this._logger.error(`${this.namespaceLog} Can not decrypt attribute ${attr}: ${e.message}`)));
|
|
8843
|
+
// remove encrypted native from supported features, otherwise this can cause issues, if no adapter upload done with js-c v3+ yet
|
|
8844
|
+
const idx = this.SUPPORTED_FEATURES.indexOf('ADAPTER_AUTO_DECRYPT_NATIVE');
|
|
8845
|
+
if (idx !== -1) {
|
|
8846
|
+
this.SUPPORTED_FEATURES.splice(idx, 1);
|
|
8838
8847
|
}
|
|
8839
8848
|
}
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
this.SUPPORTED_FEATURES.splice(idx, 1);
|
|
8849
|
+
// Wait till all attributes decrypted
|
|
8850
|
+
await Promise.all(promises);
|
|
8851
|
+
if (!this.#states) {
|
|
8852
|
+
// if this.adapterStates was destroyed, we should not continue
|
|
8853
|
+
return;
|
|
8846
8854
|
}
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
}
|
|
8854
|
-
this.outputCount++;
|
|
8855
|
-
// set current loglevel
|
|
8856
|
-
this.#states.setState(`system.adapter.${this.namespace}.logLevel`, {
|
|
8857
|
-
val: this._config.log.level,
|
|
8858
|
-
ack: true,
|
|
8859
|
-
from: `system.adapter.${this.namespace}`
|
|
8860
|
-
});
|
|
8861
|
-
if (this._options.instance === undefined) {
|
|
8862
|
-
this.version = this.pack?.version
|
|
8863
|
-
? this.pack.version
|
|
8864
|
-
: this.ioPack?.common
|
|
8865
|
-
? this.ioPack.common.version
|
|
8866
|
-
: 'unknown';
|
|
8867
|
-
// display if it's a non-official version - only if installedFrom is explicitly given and differs it's not npm
|
|
8868
|
-
// display if it's a non-official version - only if installedFrom is explicitly given and differs it's not npm
|
|
8869
|
-
const isNpmVersion = isInstalledFromNpm({
|
|
8870
|
-
adapterName: this.name,
|
|
8871
|
-
installedFrom: this.ioPack.common.installedFrom
|
|
8855
|
+
this.outputCount++;
|
|
8856
|
+
// set current loglevel
|
|
8857
|
+
this.#states.setState(`system.adapter.${this.namespace}.logLevel`, {
|
|
8858
|
+
val: this._config.log.level,
|
|
8859
|
+
ack: true,
|
|
8860
|
+
from: `system.adapter.${this.namespace}`
|
|
8872
8861
|
});
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
val: !!this.startedInCompactMode
|
|
8862
|
+
if (this._options.instance === undefined) {
|
|
8863
|
+
this.version = this.pack?.version
|
|
8864
|
+
? this.pack.version
|
|
8865
|
+
: this.ioPack?.common
|
|
8866
|
+
? this.ioPack.common.version
|
|
8867
|
+
: 'unknown';
|
|
8868
|
+
// display if it's a non-official version - only if installedFrom is explicitly given and differs it's not npm
|
|
8869
|
+
const isNpmVersion = isInstalledFromNpm({
|
|
8870
|
+
adapterName: this.name,
|
|
8871
|
+
installedFrom: this.ioPack.common.installedFrom
|
|
8884
8872
|
});
|
|
8885
|
-
this.
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
this
|
|
8890
|
-
this
|
|
8891
|
-
|
|
8892
|
-
this.#states.setState(`${id}.
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
tools.measureEventLoopLag(1_000, lag => {
|
|
8897
|
-
if (lag) {
|
|
8898
|
-
this.eventLoopLags.push(lag);
|
|
8899
|
-
}
|
|
8873
|
+
this._logger.info(`${this.namespaceLog} starting. Version ${this.version} ${!isNpmVersion ? `(non-npm: ${this.ioPack.common.installedFrom}) ` : ''}in ${this.adapterDir}, node: ${process.version}, js-controller: ${controllerVersion}`);
|
|
8874
|
+
this._config.system = this._config.system || {};
|
|
8875
|
+
this._config.system.statisticsInterval = parseInt(this._config.system.statisticsInterval, 10) || 15_000;
|
|
8876
|
+
if (!this._config.isInstall) {
|
|
8877
|
+
this._reportInterval = setInterval(() => this._reportStatus(), this._config.system.statisticsInterval);
|
|
8878
|
+
this._reportStatus();
|
|
8879
|
+
const id = `system.adapter.${this.namespace}`;
|
|
8880
|
+
this.#states.setState(`${id}.compactMode`, {
|
|
8881
|
+
ack: true,
|
|
8882
|
+
from: id,
|
|
8883
|
+
val: this.startedInCompactMode
|
|
8900
8884
|
});
|
|
8885
|
+
this.outputCount++;
|
|
8886
|
+
if (this.startedInCompactMode) {
|
|
8887
|
+
this.#states.setState(`${id}.cpu`, { ack: true, from: id, val: 0 });
|
|
8888
|
+
this.#states.setState(`${id}.cputime`, { ack: true, from: id, val: 0 });
|
|
8889
|
+
this.#states.setState(`${id}.memRss`, { val: 0, ack: true, from: id });
|
|
8890
|
+
this.#states.setState(`${id}.memHeapTotal`, { val: 0, ack: true, from: id });
|
|
8891
|
+
this.#states.setState(`${id}.memHeapUsed`, { val: 0, ack: true, from: id });
|
|
8892
|
+
this.#states.setState(`${id}.eventLoopLag`, { val: 0, ack: true, from: id });
|
|
8893
|
+
this.outputCount += 6;
|
|
8894
|
+
}
|
|
8895
|
+
else {
|
|
8896
|
+
tools.measureEventLoopLag(1_000, lag => {
|
|
8897
|
+
if (lag) {
|
|
8898
|
+
this.eventLoopLags.push(lag);
|
|
8899
|
+
}
|
|
8900
|
+
});
|
|
8901
|
+
}
|
|
8901
8902
|
}
|
|
8902
8903
|
}
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8904
|
+
if (adapterConfig && 'common' in adapterConfig && adapterConfig.common.restartSchedule) {
|
|
8905
|
+
try {
|
|
8906
|
+
this._schedule = await import('node-schedule');
|
|
8907
|
+
}
|
|
8908
|
+
catch {
|
|
8909
|
+
this._logger.error(`${this.namespaceLog} Cannot load node-schedule. Scheduled restart is disabled`);
|
|
8910
|
+
}
|
|
8911
|
+
if (this._schedule) {
|
|
8912
|
+
this._logger.debug(`${this.namespaceLog} Schedule restart: ${adapterConfig.common.restartSchedule}`);
|
|
8913
|
+
this._restartScheduleJob = this._schedule.scheduleJob(adapterConfig.common.restartSchedule, () => {
|
|
8914
|
+
this._logger.info(`${this.namespaceLog} Scheduled restart.`);
|
|
8915
|
+
this._stop({ isPause: false, isScheduled: true });
|
|
8916
|
+
});
|
|
8917
|
+
}
|
|
8910
8918
|
}
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
this.
|
|
8914
|
-
|
|
8915
|
-
|
|
8919
|
+
// auto oStates
|
|
8920
|
+
if (this._options.states) {
|
|
8921
|
+
this.getStates('*', null, (err, _states) => {
|
|
8922
|
+
if (this._stopInProgress) {
|
|
8923
|
+
return;
|
|
8924
|
+
}
|
|
8925
|
+
this.oStates = _states;
|
|
8926
|
+
this.subscribeStates('*');
|
|
8927
|
+
if (this._firstConnection) {
|
|
8928
|
+
this._firstConnection = false;
|
|
8929
|
+
this._callReadyHandler();
|
|
8930
|
+
}
|
|
8931
|
+
this.adapterReady = true;
|
|
8916
8932
|
});
|
|
8917
8933
|
}
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
if (this._options.states) {
|
|
8921
|
-
this.getStates('*', null, (err, _states) => {
|
|
8922
|
-
if (this._stopInProgress) {
|
|
8923
|
-
return;
|
|
8924
|
-
}
|
|
8925
|
-
this.oStates = _states;
|
|
8926
|
-
this.subscribeStates('*');
|
|
8927
|
-
if (this._firstConnection) {
|
|
8928
|
-
this._firstConnection = false;
|
|
8929
|
-
this._callReadyHandler();
|
|
8930
|
-
}
|
|
8934
|
+
else if (!this._stopInProgress) {
|
|
8935
|
+
this._callReadyHandler();
|
|
8931
8936
|
this.adapterReady = true;
|
|
8932
|
-
}
|
|
8933
|
-
}
|
|
8934
|
-
else if (!this._stopInProgress) {
|
|
8935
|
-
this._callReadyHandler();
|
|
8936
|
-
this.adapterReady = true;
|
|
8937
|
-
}
|
|
8937
|
+
}
|
|
8938
|
+
});
|
|
8938
8939
|
}
|
|
8939
8940
|
/**
|
|
8940
8941
|
* Calls the ready handler, if it is an install run it calls the install handler instead
|