@iobroker/legacy-testing 0.3.3 → 0.3.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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/setup.js +13 -30
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Legacy test modules for ioBroker
|
|
|
11
11
|
|
|
12
12
|
## Changelog
|
|
13
13
|
<!-- ### **WORK IN PROGRESS** -->
|
|
14
|
-
### 0.3.
|
|
14
|
+
### 0.3.4 (2023-05-08)
|
|
15
15
|
* (bluefox) Added possibility to install additional adapters at start
|
|
16
16
|
* (bluefox) Added setOfflineState/getOfflineState
|
|
17
17
|
|
package/package.json
CHANGED
package/setup.js
CHANGED
|
@@ -709,9 +709,11 @@ function startController(isStartAdapter, onObjectChange, onStateChange, callback
|
|
|
709
709
|
onObjectChange = undefined;
|
|
710
710
|
}
|
|
711
711
|
|
|
712
|
-
if (pids
|
|
712
|
+
if (pids.controller) {
|
|
713
713
|
console.error('Controller is already started!');
|
|
714
714
|
} else {
|
|
715
|
+
pids.controller = true;
|
|
716
|
+
|
|
715
717
|
console.log('startController...');
|
|
716
718
|
try {
|
|
717
719
|
const config = require(`${rootDir}tmp/${appName}-data/${appName}.json`);
|
|
@@ -762,7 +764,7 @@ function startController(isStartAdapter, onObjectChange, onStateChange, callback
|
|
|
762
764
|
|
|
763
765
|
// Just open in memory DB itself
|
|
764
766
|
const statePath = require.resolve(`@iobroker/db-states-${config.states.type}`, {
|
|
765
|
-
paths: [
|
|
767
|
+
paths: [`${rootDir}tmp/node_modules`, rootDir, `${rootDir}tmp/node_modules/${appName}.js-controller`],
|
|
766
768
|
});
|
|
767
769
|
console.log(`States Path: ${statePath}`);
|
|
768
770
|
const States = require(statePath).Server;
|
|
@@ -815,34 +817,13 @@ function startController(isStartAdapter, onObjectChange, onStateChange, callback
|
|
|
815
817
|
}
|
|
816
818
|
}
|
|
817
819
|
|
|
818
|
-
function stopAdapter(cb) {
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
console.error('Controller is not running!');
|
|
822
|
-
cb && setTimeout(() => cb(false), 0);
|
|
823
|
-
} else {
|
|
824
|
-
adaptersStarted[id] = false;
|
|
825
|
-
pids[id].on('exit', (code, signal) => {
|
|
826
|
-
if (pids[id]) {
|
|
827
|
-
console.log(`child process terminated due to receipt of signal ${signal}`);
|
|
828
|
-
cb && cb();
|
|
829
|
-
pids[id] = null;
|
|
830
|
-
}
|
|
831
|
-
});
|
|
832
|
-
|
|
833
|
-
pids[id].on('close', (/* code, signal */) => {
|
|
834
|
-
if (pids[id]) {
|
|
835
|
-
cb && cb();
|
|
836
|
-
pids[id] = null;
|
|
837
|
-
}
|
|
838
|
-
});
|
|
839
|
-
|
|
840
|
-
pids[id].kill('SIGTERM');
|
|
841
|
-
}
|
|
820
|
+
async function stopAdapter(cb) {
|
|
821
|
+
await stopCustomAdapter();
|
|
822
|
+
cb && cb();
|
|
842
823
|
}
|
|
843
824
|
|
|
844
825
|
function stopCustomAdapter(adapterName, adapterInstance) {
|
|
845
|
-
const id = `${adapterName}.${adapterInstance || 0}`;
|
|
826
|
+
const id = `${adapterName || pkg.name.split('.')[1]}.${adapterInstance || 0}`;
|
|
846
827
|
if (!pids[id]) {
|
|
847
828
|
console.error(`Adapter instance ${id} is not running!`);
|
|
848
829
|
return Promise.resolve();
|
|
@@ -881,10 +862,11 @@ function _stopController() {
|
|
|
881
862
|
}
|
|
882
863
|
|
|
883
864
|
function stopController(cb) {
|
|
865
|
+
const id = `${pkg.name.split('.')[1]}.0`;
|
|
884
866
|
let timeout;
|
|
885
867
|
if (objects) {
|
|
886
|
-
console.log(`Set system.adapter.${
|
|
887
|
-
objects.setObject(`system.adapter.${
|
|
868
|
+
console.log(`Set system.adapter.${id}`);
|
|
869
|
+
objects.setObject(`system.adapter.${id}`, {
|
|
888
870
|
common: {
|
|
889
871
|
enabled: false,
|
|
890
872
|
},
|
|
@@ -903,6 +885,7 @@ function stopController(cb) {
|
|
|
903
885
|
cb(true);
|
|
904
886
|
cb = null;
|
|
905
887
|
}
|
|
888
|
+
pids.controller = null;
|
|
906
889
|
});
|
|
907
890
|
|
|
908
891
|
timeout = setTimeout(() => {
|
|
@@ -915,7 +898,7 @@ function stopController(cb) {
|
|
|
915
898
|
cb(false);
|
|
916
899
|
cb = null;
|
|
917
900
|
}
|
|
918
|
-
pids
|
|
901
|
+
pids.controller = null;
|
|
919
902
|
}, 5000);
|
|
920
903
|
}
|
|
921
904
|
|