@iobroker/js-controller-adapter 6.0.7 → 6.0.9
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.d.ts +6 -0
- package/build/cjs/lib/adapter/adapter.js +190 -186
- package/build/cjs/lib/adapter/adapter.js.map +2 -2
- package/build/esm/lib/adapter/adapter.d.ts +6 -0
- package/build/esm/lib/adapter/adapter.d.ts.map +1 -1
- package/build/esm/lib/adapter/adapter.js +243 -234
- package/build/esm/lib/adapter/adapter.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +12 -11
|
@@ -399,6 +399,12 @@ export declare class AdapterClass extends EventEmitter {
|
|
|
399
399
|
/** Controller for messaging related functionality */
|
|
400
400
|
private readonly uiMessagingController;
|
|
401
401
|
constructor(options: AdapterOptions | string);
|
|
402
|
+
/**
|
|
403
|
+
* Get the adapter scoped package identifier of a node module
|
|
404
|
+
*
|
|
405
|
+
* @param moduleName name of the node module
|
|
406
|
+
*/
|
|
407
|
+
getAdapterScopedPackageIdentifier(moduleName: string): string;
|
|
402
408
|
installNodeModule(moduleName: string, options: InstallNodeModuleOptions): Promise<CommandResult>;
|
|
403
409
|
private _installNodeModule;
|
|
404
410
|
/**
|
|
@@ -327,6 +327,9 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
327
327
|
this.setExecutableCapabilities = import_js_controller_common.tools.setExecutableCapabilities;
|
|
328
328
|
this._init();
|
|
329
329
|
}
|
|
330
|
+
getAdapterScopedPackageIdentifier(moduleName) {
|
|
331
|
+
return (0, import_utils.getAdapterScopedPackageIdentifier)({ moduleName, namespace: this.namespace });
|
|
332
|
+
}
|
|
330
333
|
installNodeModule(moduleNameOrUrl, options) {
|
|
331
334
|
import_validator.Validator.assertString(moduleNameOrUrl, "moduleNameOrUrl");
|
|
332
335
|
import_validator.Validator.assertObject(options, "options");
|
|
@@ -5828,8 +5831,8 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
5828
5831
|
}
|
|
5829
5832
|
if (this.pluginHandler.isPluginActive(pluginName) !== state.val) {
|
|
5830
5833
|
if (state.val) {
|
|
5831
|
-
if (!this.pluginHandler.
|
|
5832
|
-
this.pluginHandler.
|
|
5834
|
+
if (!this.pluginHandler.isPluginInstanciated(pluginName)) {
|
|
5835
|
+
this.pluginHandler.instanciatePlugin(pluginName, this.pluginHandler.getPluginConfig(pluginName) || {}, thisDir);
|
|
5833
5836
|
this.pluginHandler.setDatabaseForPlugin(pluginName, this.#objects, this.#states);
|
|
5834
5837
|
this.pluginHandler.initPlugin(pluginName, this.adapterConfig || {});
|
|
5835
5838
|
}
|
|
@@ -6129,208 +6132,209 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
6129
6132
|
return;
|
|
6130
6133
|
}
|
|
6131
6134
|
this.pluginHandler.setDatabaseForPlugins(this.#objects, this.#states);
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
return;
|
|
6135
|
-
}
|
|
6136
|
-
this.#states.subscribe(`system.adapter.${this.namespace}.plugins.*`);
|
|
6137
|
-
if (this._options.instance === void 0) {
|
|
6138
|
-
if (!adapterConfig || !("common" in adapterConfig) || !adapterConfig.common.enabled) {
|
|
6139
|
-
if (adapterConfig && "common" in adapterConfig && adapterConfig.common.enabled !== void 0) {
|
|
6140
|
-
!this._config.isInstall && this._logger.error(`${this.namespaceLog} adapter disabled`);
|
|
6141
|
-
} else {
|
|
6142
|
-
!this._config.isInstall && this._logger.error(`${this.namespaceLog} no config found for adapter`);
|
|
6143
|
-
}
|
|
6144
|
-
if (!this._config.isInstall && (!process.argv || !this._config.forceIfDisabled)) {
|
|
6145
|
-
const id = `system.adapter.${this.namespace}`;
|
|
6146
|
-
this.outputCount += 2;
|
|
6147
|
-
this.#states.setState(`${id}.alive`, { val: true, ack: true, expire: 30, from: id });
|
|
6148
|
-
let done = false;
|
|
6149
|
-
this.#states.setState(`${id}.connected`, {
|
|
6150
|
-
val: true,
|
|
6151
|
-
ack: true,
|
|
6152
|
-
expire: 30,
|
|
6153
|
-
from: id
|
|
6154
|
-
}, () => {
|
|
6155
|
-
if (!done) {
|
|
6156
|
-
done = true;
|
|
6157
|
-
this.terminate(import_js_controller_common.EXIT_CODES.NO_ADAPTER_CONFIG_FOUND);
|
|
6158
|
-
}
|
|
6159
|
-
});
|
|
6160
|
-
setTimeout(() => {
|
|
6161
|
-
if (!done) {
|
|
6162
|
-
done = true;
|
|
6163
|
-
this.terminate(import_js_controller_common.EXIT_CODES.NO_ADAPTER_CONFIG_FOUND);
|
|
6164
|
-
}
|
|
6165
|
-
}, 1e3);
|
|
6166
|
-
return;
|
|
6167
|
-
}
|
|
6168
|
-
}
|
|
6169
|
-
if (!this._config.isInstall && (!adapterConfig || !("_id" in adapterConfig))) {
|
|
6170
|
-
this._logger.error(`${this.namespaceLog} invalid config: no _id found`);
|
|
6171
|
-
this.terminate(import_js_controller_common.EXIT_CODES.INVALID_ADAPTER_ID);
|
|
6135
|
+
this.pluginHandler.initPlugins(adapterConfig || {}, async () => {
|
|
6136
|
+
if (!this.#states || !this.#objects || this.terminated) {
|
|
6172
6137
|
return;
|
|
6173
6138
|
}
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6139
|
+
this.#states.subscribe(`system.adapter.${this.namespace}.plugins.*`);
|
|
6140
|
+
if (this._options.instance === void 0) {
|
|
6141
|
+
if (!adapterConfig || !("common" in adapterConfig) || !adapterConfig.common.enabled) {
|
|
6142
|
+
if (adapterConfig && "common" in adapterConfig && adapterConfig.common.enabled !== void 0) {
|
|
6143
|
+
!this._config.isInstall && this._logger.error(`${this.namespaceLog} adapter disabled`);
|
|
6144
|
+
} else {
|
|
6145
|
+
!this._config.isInstall && this._logger.error(`${this.namespaceLog} no config found for adapter`);
|
|
6146
|
+
}
|
|
6147
|
+
if (!this._config.isInstall && (!process.argv || !this._config.forceIfDisabled)) {
|
|
6148
|
+
const id = `system.adapter.${this.namespace}`;
|
|
6149
|
+
this.outputCount += 2;
|
|
6150
|
+
this.#states.setState(`${id}.alive`, { val: true, ack: true, expire: 30, from: id });
|
|
6151
|
+
let done = false;
|
|
6152
|
+
this.#states.setState(`${id}.connected`, {
|
|
6153
|
+
val: true,
|
|
6154
|
+
ack: true,
|
|
6155
|
+
expire: 30,
|
|
6156
|
+
from: id
|
|
6157
|
+
}, () => {
|
|
6158
|
+
if (!done) {
|
|
6159
|
+
done = true;
|
|
6160
|
+
this.terminate(import_js_controller_common.EXIT_CODES.NO_ADAPTER_CONFIG_FOUND);
|
|
6161
|
+
}
|
|
6162
|
+
});
|
|
6163
|
+
setTimeout(() => {
|
|
6164
|
+
if (!done) {
|
|
6165
|
+
done = true;
|
|
6166
|
+
this.terminate(import_js_controller_common.EXIT_CODES.NO_ADAPTER_CONFIG_FOUND);
|
|
6167
|
+
}
|
|
6168
|
+
}, 1e3);
|
|
6169
|
+
return;
|
|
6170
|
+
}
|
|
6171
|
+
}
|
|
6172
|
+
if (!this._config.isInstall && (!adapterConfig || !("_id" in adapterConfig))) {
|
|
6173
|
+
this._logger.error(`${this.namespaceLog} invalid config: no _id found`);
|
|
6180
6174
|
this.terminate(import_js_controller_common.EXIT_CODES.INVALID_ADAPTER_ID);
|
|
6181
6175
|
return;
|
|
6182
6176
|
}
|
|
6183
|
-
name
|
|
6184
|
-
instance
|
|
6177
|
+
let name;
|
|
6178
|
+
let instance;
|
|
6179
|
+
if (!this._config.isInstall) {
|
|
6180
|
+
const tmp = adapterConfig._id.match(/^system\.adapter\.([a-zA-Z0-9-_]+)\.([0-9]+)$/);
|
|
6181
|
+
if (!tmp) {
|
|
6182
|
+
this._logger.error(`${this.namespaceLog} invalid config`);
|
|
6183
|
+
this.terminate(import_js_controller_common.EXIT_CODES.INVALID_ADAPTER_ID);
|
|
6184
|
+
return;
|
|
6185
|
+
}
|
|
6186
|
+
name = tmp[1];
|
|
6187
|
+
instance = parseInt(tmp[2]) || 0;
|
|
6188
|
+
} else {
|
|
6189
|
+
name = this.name;
|
|
6190
|
+
instance = 0;
|
|
6191
|
+
adapterConfig = adapterConfig || {
|
|
6192
|
+
common: { mode: "once", name, protectedNative: [] },
|
|
6193
|
+
native: {}
|
|
6194
|
+
};
|
|
6195
|
+
}
|
|
6196
|
+
if (adapterConfig.common.loglevel && !this.overwriteLogLevel) {
|
|
6197
|
+
for (const trans of Object.values(this._logger.transports)) {
|
|
6198
|
+
if (!trans._defaultConfigLoglevel) {
|
|
6199
|
+
trans.level = adapterConfig.common.loglevel;
|
|
6200
|
+
}
|
|
6201
|
+
}
|
|
6202
|
+
this._config.log.level = adapterConfig.common.loglevel;
|
|
6203
|
+
}
|
|
6204
|
+
this.name = adapterConfig.common.name;
|
|
6205
|
+
this.instance = instance;
|
|
6206
|
+
this.namespace = `${name}.${instance}`;
|
|
6207
|
+
this.namespaceLog = this.namespace + (this.startedInCompactMode ? " (COMPACT)" : ` (${process.pid})`);
|
|
6208
|
+
if (!this.startedInCompactMode) {
|
|
6209
|
+
process.title = `io.${this.namespace}`;
|
|
6210
|
+
}
|
|
6211
|
+
this.config = adapterConfig.native;
|
|
6212
|
+
this.host = adapterConfig.common.host;
|
|
6213
|
+
this.common = adapterConfig.common;
|
|
6214
|
+
if (adapterConfig.common.mode === "schedule" || adapterConfig.common.mode === "once") {
|
|
6215
|
+
this.stop = (params) => this._stop({ ...params, isPause: true });
|
|
6216
|
+
} else if (this.startedInCompactMode) {
|
|
6217
|
+
this.stop = (params) => this._stop({ ...params, isPause: false });
|
|
6218
|
+
this.kill = this.stop;
|
|
6219
|
+
} else {
|
|
6220
|
+
this.stop = (params) => this._stop({ ...params, isPause: false });
|
|
6221
|
+
}
|
|
6222
|
+
this.#states.subscribe(`${import_constants2.SYSTEM_ADAPTER_PREFIX}*.logging`);
|
|
6223
|
+
if (typeof this._options.message === "function" && !(0, import_utils.isMessageboxSupported)(adapterConfig.common)) {
|
|
6224
|
+
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.`);
|
|
6225
|
+
} else if ((0, import_utils.isMessageboxSupported)(adapterConfig.common)) {
|
|
6226
|
+
this.mboxSubscribed = true;
|
|
6227
|
+
this.#states.subscribeMessage(`system.adapter.${this.namespace}`);
|
|
6228
|
+
}
|
|
6185
6229
|
} else {
|
|
6186
|
-
name = this.name;
|
|
6187
|
-
instance = 0;
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
};
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
this.
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
this.
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
this.common = adapterConfig.common;
|
|
6211
|
-
if (adapterConfig.common.mode === "schedule" || adapterConfig.common.mode === "once") {
|
|
6212
|
-
this.stop = (params) => this._stop({ ...params, isPause: true });
|
|
6213
|
-
} else if (this.startedInCompactMode) {
|
|
6214
|
-
this.stop = (params) => this._stop({ ...params, isPause: false });
|
|
6215
|
-
this.kill = this.stop;
|
|
6230
|
+
this.name = adapterConfig.name || this.name;
|
|
6231
|
+
this.instance = adapterConfig.instance || 0;
|
|
6232
|
+
this.namespace = `${this.name}.${this.instance}`;
|
|
6233
|
+
this.namespaceLog = this.namespace + (this.startedInCompactMode ? " (COMPACT)" : ` (${process.pid})`);
|
|
6234
|
+
this.config = adapterConfig.native || {};
|
|
6235
|
+
this.common = adapterConfig.common || {};
|
|
6236
|
+
this.host = this.common?.host || import_js_controller_common.tools.getHostName() || import_node_os.default.hostname();
|
|
6237
|
+
}
|
|
6238
|
+
this.adapterConfig = adapterConfig;
|
|
6239
|
+
this._utils = new import_validator.Validator(this.#objects, this.#states, this.namespaceLog, this._logger, this.namespace, this._namespaceRegExp);
|
|
6240
|
+
this.log = new import_log.Log(this.namespaceLog, this._config.log.level, this._logger);
|
|
6241
|
+
await this._createInstancesObjects(adapterConfig);
|
|
6242
|
+
if (this._options.objects) {
|
|
6243
|
+
this.oObjects = await this.getAdapterObjectsAsync();
|
|
6244
|
+
await this.subscribeObjectsAsync("*");
|
|
6245
|
+
}
|
|
6246
|
+
await this.getSystemSecret();
|
|
6247
|
+
const promises = [];
|
|
6248
|
+
if (Array.isArray(adapterConfig.encryptedNative)) {
|
|
6249
|
+
for (const attr of adapterConfig.encryptedNative) {
|
|
6250
|
+
if (typeof this.config[attr] === "string") {
|
|
6251
|
+
promises.push(this.getEncryptedConfig(attr).then((decryptedValue) => this.config[attr] = decryptedValue).catch((e) => this._logger.error(`${this.namespaceLog} Can not decrypt attribute ${attr}: ${e.message}`)));
|
|
6252
|
+
}
|
|
6253
|
+
}
|
|
6216
6254
|
} else {
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
if (typeof this._options.message === "function" && !(0, import_utils.isMessageboxSupported)(adapterConfig.common)) {
|
|
6221
|
-
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.`);
|
|
6222
|
-
} else if ((0, import_utils.isMessageboxSupported)(adapterConfig.common)) {
|
|
6223
|
-
this.mboxSubscribed = true;
|
|
6224
|
-
this.#states.subscribeMessage(`system.adapter.${this.namespace}`);
|
|
6225
|
-
}
|
|
6226
|
-
} else {
|
|
6227
|
-
this.name = adapterConfig.name || this.name;
|
|
6228
|
-
this.instance = adapterConfig.instance || 0;
|
|
6229
|
-
this.namespace = `${this.name}.${this.instance}`;
|
|
6230
|
-
this.namespaceLog = this.namespace + (this.startedInCompactMode ? " (COMPACT)" : ` (${process.pid})`);
|
|
6231
|
-
this.config = adapterConfig.native || {};
|
|
6232
|
-
this.common = adapterConfig.common || {};
|
|
6233
|
-
this.host = this.common?.host || import_js_controller_common.tools.getHostName() || import_node_os.default.hostname();
|
|
6234
|
-
}
|
|
6235
|
-
this.adapterConfig = adapterConfig;
|
|
6236
|
-
this._utils = new import_validator.Validator(this.#objects, this.#states, this.namespaceLog, this._logger, this.namespace, this._namespaceRegExp);
|
|
6237
|
-
this.log = new import_log.Log(this.namespaceLog, this._config.log.level, this._logger);
|
|
6238
|
-
await this._createInstancesObjects(adapterConfig);
|
|
6239
|
-
if (this._options.objects) {
|
|
6240
|
-
this.oObjects = await this.getAdapterObjectsAsync();
|
|
6241
|
-
await this.subscribeObjectsAsync("*");
|
|
6242
|
-
}
|
|
6243
|
-
await this.getSystemSecret();
|
|
6244
|
-
const promises = [];
|
|
6245
|
-
if (Array.isArray(adapterConfig.encryptedNative)) {
|
|
6246
|
-
for (const attr of adapterConfig.encryptedNative) {
|
|
6247
|
-
if (typeof this.config[attr] === "string") {
|
|
6248
|
-
promises.push(this.getEncryptedConfig(attr).then((decryptedValue) => this.config[attr] = decryptedValue).catch((e) => this._logger.error(`${this.namespaceLog} Can not decrypt attribute ${attr}: ${e.message}`)));
|
|
6255
|
+
const idx = this.SUPPORTED_FEATURES.indexOf("ADAPTER_AUTO_DECRYPT_NATIVE");
|
|
6256
|
+
if (idx !== -1) {
|
|
6257
|
+
this.SUPPORTED_FEATURES.splice(idx, 1);
|
|
6249
6258
|
}
|
|
6250
6259
|
}
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
this.SUPPORTED_FEATURES.splice(idx, 1);
|
|
6260
|
+
await Promise.all(promises);
|
|
6261
|
+
if (!this.#states) {
|
|
6262
|
+
return;
|
|
6255
6263
|
}
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
this.outputCount++;
|
|
6262
|
-
this.#states.setState(`system.adapter.${this.namespace}.logLevel`, {
|
|
6263
|
-
val: this._config.log.level,
|
|
6264
|
-
ack: true,
|
|
6265
|
-
from: `system.adapter.${this.namespace}`
|
|
6266
|
-
});
|
|
6267
|
-
if (this._options.instance === void 0) {
|
|
6268
|
-
this.version = this.pack?.version ? this.pack.version : this.ioPack?.common ? this.ioPack.common.version : "unknown";
|
|
6269
|
-
const isNpmVersion = (0, import_js_controller_common.isInstalledFromNpm)({
|
|
6270
|
-
adapterName: this.name,
|
|
6271
|
-
installedFrom: this.ioPack.common.installedFrom
|
|
6264
|
+
this.outputCount++;
|
|
6265
|
+
this.#states.setState(`system.adapter.${this.namespace}.logLevel`, {
|
|
6266
|
+
val: this._config.log.level,
|
|
6267
|
+
ack: true,
|
|
6268
|
+
from: `system.adapter.${this.namespace}`
|
|
6272
6269
|
});
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
this._reportStatus();
|
|
6279
|
-
const id = `system.adapter.${this.namespace}`;
|
|
6280
|
-
this.#states.setState(`${id}.compactMode`, {
|
|
6281
|
-
ack: true,
|
|
6282
|
-
from: id,
|
|
6283
|
-
val: !!this.startedInCompactMode
|
|
6270
|
+
if (this._options.instance === void 0) {
|
|
6271
|
+
this.version = this.pack?.version ? this.pack.version : this.ioPack?.common ? this.ioPack.common.version : "unknown";
|
|
6272
|
+
const isNpmVersion = (0, import_js_controller_common.isInstalledFromNpm)({
|
|
6273
|
+
adapterName: this.name,
|
|
6274
|
+
installedFrom: this.ioPack.common.installedFrom
|
|
6284
6275
|
});
|
|
6285
|
-
this.
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
this
|
|
6290
|
-
this
|
|
6291
|
-
|
|
6292
|
-
this.#states.setState(`${id}.
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
if (lag) {
|
|
6297
|
-
this.eventLoopLags.push(lag);
|
|
6298
|
-
}
|
|
6276
|
+
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}`);
|
|
6277
|
+
this._config.system = this._config.system || {};
|
|
6278
|
+
this._config.system.statisticsInterval = parseInt(this._config.system.statisticsInterval, 10) || 15e3;
|
|
6279
|
+
if (!this._config.isInstall) {
|
|
6280
|
+
this._reportInterval = setInterval(() => this._reportStatus(), this._config.system.statisticsInterval);
|
|
6281
|
+
this._reportStatus();
|
|
6282
|
+
const id = `system.adapter.${this.namespace}`;
|
|
6283
|
+
this.#states.setState(`${id}.compactMode`, {
|
|
6284
|
+
ack: true,
|
|
6285
|
+
from: id,
|
|
6286
|
+
val: this.startedInCompactMode
|
|
6299
6287
|
});
|
|
6288
|
+
this.outputCount++;
|
|
6289
|
+
if (this.startedInCompactMode) {
|
|
6290
|
+
this.#states.setState(`${id}.cpu`, { ack: true, from: id, val: 0 });
|
|
6291
|
+
this.#states.setState(`${id}.cputime`, { ack: true, from: id, val: 0 });
|
|
6292
|
+
this.#states.setState(`${id}.memRss`, { val: 0, ack: true, from: id });
|
|
6293
|
+
this.#states.setState(`${id}.memHeapTotal`, { val: 0, ack: true, from: id });
|
|
6294
|
+
this.#states.setState(`${id}.memHeapUsed`, { val: 0, ack: true, from: id });
|
|
6295
|
+
this.#states.setState(`${id}.eventLoopLag`, { val: 0, ack: true, from: id });
|
|
6296
|
+
this.outputCount += 6;
|
|
6297
|
+
} else {
|
|
6298
|
+
import_js_controller_common.tools.measureEventLoopLag(1e3, (lag) => {
|
|
6299
|
+
if (lag) {
|
|
6300
|
+
this.eventLoopLags.push(lag);
|
|
6301
|
+
}
|
|
6302
|
+
});
|
|
6303
|
+
}
|
|
6300
6304
|
}
|
|
6301
6305
|
}
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
this._logger.error(`${this.namespaceLog} Cannot load node-schedule. Scheduled restart is disabled`);
|
|
6308
|
-
}
|
|
6309
|
-
if (this._schedule) {
|
|
6310
|
-
this._logger.debug(`${this.namespaceLog} Schedule restart: ${adapterConfig.common.restartSchedule}`);
|
|
6311
|
-
this._restartScheduleJob = this._schedule.scheduleJob(adapterConfig.common.restartSchedule, () => {
|
|
6312
|
-
this._logger.info(`${this.namespaceLog} Scheduled restart.`);
|
|
6313
|
-
this._stop({ isPause: false, isScheduled: true });
|
|
6314
|
-
});
|
|
6315
|
-
}
|
|
6316
|
-
}
|
|
6317
|
-
if (this._options.states) {
|
|
6318
|
-
this.getStates("*", null, (err, _states) => {
|
|
6319
|
-
if (this._stopInProgress) {
|
|
6320
|
-
return;
|
|
6306
|
+
if (adapterConfig && "common" in adapterConfig && adapterConfig.common.restartSchedule) {
|
|
6307
|
+
try {
|
|
6308
|
+
this._schedule = await import("node-schedule");
|
|
6309
|
+
} catch {
|
|
6310
|
+
this._logger.error(`${this.namespaceLog} Cannot load node-schedule. Scheduled restart is disabled`);
|
|
6321
6311
|
}
|
|
6322
|
-
this.
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6312
|
+
if (this._schedule) {
|
|
6313
|
+
this._logger.debug(`${this.namespaceLog} Schedule restart: ${adapterConfig.common.restartSchedule}`);
|
|
6314
|
+
this._restartScheduleJob = this._schedule.scheduleJob(adapterConfig.common.restartSchedule, () => {
|
|
6315
|
+
this._logger.info(`${this.namespaceLog} Scheduled restart.`);
|
|
6316
|
+
this._stop({ isPause: false, isScheduled: true });
|
|
6317
|
+
});
|
|
6327
6318
|
}
|
|
6319
|
+
}
|
|
6320
|
+
if (this._options.states) {
|
|
6321
|
+
this.getStates("*", null, (err, _states) => {
|
|
6322
|
+
if (this._stopInProgress) {
|
|
6323
|
+
return;
|
|
6324
|
+
}
|
|
6325
|
+
this.oStates = _states;
|
|
6326
|
+
this.subscribeStates("*");
|
|
6327
|
+
if (this._firstConnection) {
|
|
6328
|
+
this._firstConnection = false;
|
|
6329
|
+
this._callReadyHandler();
|
|
6330
|
+
}
|
|
6331
|
+
this.adapterReady = true;
|
|
6332
|
+
});
|
|
6333
|
+
} else if (!this._stopInProgress) {
|
|
6334
|
+
this._callReadyHandler();
|
|
6328
6335
|
this.adapterReady = true;
|
|
6329
|
-
}
|
|
6330
|
-
}
|
|
6331
|
-
this._callReadyHandler();
|
|
6332
|
-
this.adapterReady = true;
|
|
6333
|
-
}
|
|
6336
|
+
}
|
|
6337
|
+
});
|
|
6334
6338
|
}
|
|
6335
6339
|
_callReadyHandler() {
|
|
6336
6340
|
if (this._config.isInstall && (typeof this._options.install === "function" || this.listeners("install").length)) {
|