@abtnode/core 1.16.25-beta-fe54d1bc → 1.16.25-beta-4f765cf3
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/lib/blocklet/manager/disk.js +77 -11
- package/package.json +20 -20
|
@@ -54,6 +54,7 @@ const {
|
|
|
54
54
|
getDisplayName,
|
|
55
55
|
} = require('@blocklet/meta/lib/util');
|
|
56
56
|
const { getComponentsInternalInfo } = require('@blocklet/meta/lib/blocklet');
|
|
57
|
+
const { getRequiredComponentsLayers } = require('@blocklet/meta/lib/get-required-components-layers');
|
|
57
58
|
const { update: updateMetaFile } = require('@blocklet/meta/lib/file');
|
|
58
59
|
const { titleSchema, updateMountPointSchema, environmentNameSchema } = require('@blocklet/meta/lib/schema');
|
|
59
60
|
const { emailConfigSchema } = require('@blocklet/sdk/lib/validators/email');
|
|
@@ -100,6 +101,7 @@ const { encode } = require('@abtnode/util/lib/base32');
|
|
|
100
101
|
const formatContext = require('@abtnode/util/lib/format-context');
|
|
101
102
|
const md5 = require('@abtnode/util/lib/md5');
|
|
102
103
|
const { callFederated } = require('@abtnode/auth/lib/util/federated');
|
|
104
|
+
const pAll = require('p-all');
|
|
103
105
|
const { consumeServerlessNFT, consumeLauncherSession } = require('../../util/launcher');
|
|
104
106
|
const util = require('../../util');
|
|
105
107
|
const {
|
|
@@ -603,13 +605,68 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
603
605
|
return migrateApplicationToStructV2({ did, appSk, context, manager: this, states });
|
|
604
606
|
}
|
|
605
607
|
|
|
608
|
+
async startRequiredComponents({
|
|
609
|
+
componentDids,
|
|
610
|
+
inputComponentDids,
|
|
611
|
+
blocklet,
|
|
612
|
+
throwOnError,
|
|
613
|
+
checkHealthImmediately,
|
|
614
|
+
e2eMode,
|
|
615
|
+
context,
|
|
616
|
+
atomic,
|
|
617
|
+
}) {
|
|
618
|
+
if (!blocklet.children) {
|
|
619
|
+
return componentDids;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
const targetDid = !inputComponentDids?.length ? componentDids[0] : inputComponentDids[0];
|
|
623
|
+
|
|
624
|
+
const canStartStatus = {
|
|
625
|
+
[BlockletStatus.installed]: true,
|
|
626
|
+
[BlockletStatus.error]: true,
|
|
627
|
+
[BlockletStatus.stopped]: true,
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
const requiredDidsLayers = getRequiredComponentsLayers({
|
|
631
|
+
targetDid,
|
|
632
|
+
children: blocklet.children,
|
|
633
|
+
filter: (child) => atomic || canStartStatus[child.status],
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
// 让当前的组件的状态提前变成 starting, 不然用户会很奇怪, 明明点了启动, 但是当前组件没变化.
|
|
637
|
+
const targetChild = blocklet.children.find((x) => x.meta.did === targetDid);
|
|
638
|
+
const doc = await states.blocklet.setBlockletStatus(blocklet.meta?.did, BlockletStatus.starting, {
|
|
639
|
+
componentDids: [targetDid],
|
|
640
|
+
});
|
|
641
|
+
targetChild.status = BlockletStatus.starting;
|
|
642
|
+
this.emit(BlockletEvents.statusChange, doc);
|
|
643
|
+
|
|
644
|
+
// start by dependency
|
|
645
|
+
for (const dids of requiredDidsLayers) {
|
|
646
|
+
if (atomic) {
|
|
647
|
+
await this._start({ blocklet, throwOnError, checkHealthImmediately, e2eMode, componentDids: dids }, context);
|
|
648
|
+
} else {
|
|
649
|
+
const tasks = dids.map(
|
|
650
|
+
(x) => () =>
|
|
651
|
+
this._start({ blocklet, throwOnError, checkHealthImmediately, e2eMode, componentDids: [x] }, context)
|
|
652
|
+
);
|
|
653
|
+
await pAll(tasks, { concurrency: 4 }).catch((err) => {
|
|
654
|
+
throw new Error(err.errors.join(', '));
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// remove the components that have just been started
|
|
660
|
+
const startedDids = new Set(requiredDidsLayers.flat());
|
|
661
|
+
return componentDids.filter((x) => !startedDids.has(x));
|
|
662
|
+
}
|
|
663
|
+
|
|
606
664
|
async start(
|
|
607
665
|
{ did, throwOnError, checkHealthImmediately = false, e2eMode = false, componentDids: inputComponentDids, atomic },
|
|
608
666
|
context
|
|
609
667
|
) {
|
|
610
668
|
const blocklet = await this.ensureBlocklet(did, { e2eMode });
|
|
611
|
-
|
|
612
|
-
const componentDids = inputComponentDids?.length ? inputComponentDids : blocklet.children.map((x) => x.meta.did);
|
|
669
|
+
let componentDids = inputComponentDids?.length ? inputComponentDids : blocklet.children.map((x) => x.meta.did);
|
|
613
670
|
|
|
614
671
|
// sync component config before at first to ensure resource component config is ready
|
|
615
672
|
const serverSk = (await states.node.read()).sk;
|
|
@@ -619,20 +676,29 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
619
676
|
)
|
|
620
677
|
);
|
|
621
678
|
|
|
679
|
+
componentDids = await this.startRequiredComponents({
|
|
680
|
+
componentDids,
|
|
681
|
+
inputComponentDids,
|
|
682
|
+
blocklet,
|
|
683
|
+
throwOnError,
|
|
684
|
+
checkHealthImmediately,
|
|
685
|
+
e2eMode,
|
|
686
|
+
context,
|
|
687
|
+
atomic,
|
|
688
|
+
});
|
|
689
|
+
|
|
622
690
|
if (atomic || !blocklet.structVersion) {
|
|
623
|
-
return this._start(
|
|
624
|
-
{ did, throwOnError, checkHealthImmediately, e2eMode, componentDids: inputComponentDids },
|
|
625
|
-
context
|
|
626
|
-
);
|
|
691
|
+
return this._start({ blocklet, throwOnError, checkHealthImmediately, e2eMode, componentDids }, context);
|
|
627
692
|
}
|
|
628
693
|
|
|
629
|
-
const tasks = componentDids.map(
|
|
630
|
-
|
|
694
|
+
const tasks = componentDids.map(
|
|
695
|
+
(componentDid) => () =>
|
|
696
|
+
this._start({ blocklet, throwOnError, checkHealthImmediately, e2eMode, componentDids: [componentDid] }, context)
|
|
631
697
|
);
|
|
632
698
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
699
|
+
const rest = await pAll(tasks, { concurrency: 4 });
|
|
700
|
+
|
|
701
|
+
return rest[0];
|
|
636
702
|
}
|
|
637
703
|
|
|
638
704
|
async _start(
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.25-beta-
|
|
6
|
+
"version": "1.16.25-beta-4f765cf3",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/analytics": "1.16.25-beta-
|
|
23
|
-
"@abtnode/auth": "1.16.25-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.25-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.25-beta-
|
|
26
|
-
"@abtnode/cron": "1.16.25-beta-
|
|
27
|
-
"@abtnode/logger": "1.16.25-beta-
|
|
28
|
-
"@abtnode/models": "1.16.25-beta-
|
|
29
|
-
"@abtnode/queue": "1.16.25-beta-
|
|
30
|
-
"@abtnode/rbac": "1.16.25-beta-
|
|
31
|
-
"@abtnode/router-provider": "1.16.25-beta-
|
|
32
|
-
"@abtnode/static-server": "1.16.25-beta-
|
|
33
|
-
"@abtnode/timemachine": "1.16.25-beta-
|
|
34
|
-
"@abtnode/util": "1.16.25-beta-
|
|
22
|
+
"@abtnode/analytics": "1.16.25-beta-4f765cf3",
|
|
23
|
+
"@abtnode/auth": "1.16.25-beta-4f765cf3",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.25-beta-4f765cf3",
|
|
25
|
+
"@abtnode/constant": "1.16.25-beta-4f765cf3",
|
|
26
|
+
"@abtnode/cron": "1.16.25-beta-4f765cf3",
|
|
27
|
+
"@abtnode/logger": "1.16.25-beta-4f765cf3",
|
|
28
|
+
"@abtnode/models": "1.16.25-beta-4f765cf3",
|
|
29
|
+
"@abtnode/queue": "1.16.25-beta-4f765cf3",
|
|
30
|
+
"@abtnode/rbac": "1.16.25-beta-4f765cf3",
|
|
31
|
+
"@abtnode/router-provider": "1.16.25-beta-4f765cf3",
|
|
32
|
+
"@abtnode/static-server": "1.16.25-beta-4f765cf3",
|
|
33
|
+
"@abtnode/timemachine": "1.16.25-beta-4f765cf3",
|
|
34
|
+
"@abtnode/util": "1.16.25-beta-4f765cf3",
|
|
35
35
|
"@arcblock/did": "1.18.113",
|
|
36
36
|
"@arcblock/did-auth": "1.18.113",
|
|
37
37
|
"@arcblock/did-ext": "^1.18.113",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"@arcblock/pm2-events": "^0.0.5",
|
|
43
43
|
"@arcblock/validator": "^1.18.113",
|
|
44
44
|
"@arcblock/vc": "1.18.113",
|
|
45
|
-
"@blocklet/constant": "1.16.25-beta-
|
|
46
|
-
"@blocklet/env": "1.16.25-beta-
|
|
47
|
-
"@blocklet/meta": "1.16.25-beta-
|
|
48
|
-
"@blocklet/resolver": "1.16.25-beta-
|
|
49
|
-
"@blocklet/sdk": "1.16.25-beta-
|
|
45
|
+
"@blocklet/constant": "1.16.25-beta-4f765cf3",
|
|
46
|
+
"@blocklet/env": "1.16.25-beta-4f765cf3",
|
|
47
|
+
"@blocklet/meta": "1.16.25-beta-4f765cf3",
|
|
48
|
+
"@blocklet/resolver": "1.16.25-beta-4f765cf3",
|
|
49
|
+
"@blocklet/sdk": "1.16.25-beta-4f765cf3",
|
|
50
50
|
"@did-space/client": "^0.3.67",
|
|
51
51
|
"@fidm/x509": "^1.2.1",
|
|
52
52
|
"@ocap/mcrypto": "1.18.113",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"jest": "^29.7.0",
|
|
103
103
|
"unzipper": "^0.10.11"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "7783a4bf883bb44b4266651b04008ef65bf6c2ce"
|
|
106
106
|
}
|