@abtnode/core 1.8.17 → 1.8.18
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/hooks.js +2 -1
- package/lib/blocklet/manager/disk.js +12 -7
- package/lib/util/blocklet.js +8 -3
- package/package.json +16 -16
package/lib/blocklet/hooks.js
CHANGED
|
@@ -56,7 +56,8 @@ const preStart = async (blocklet, options) => {
|
|
|
56
56
|
return runUserHook(blocklet.env.processId, 'pre-start', options);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
const postStart = (processId, ...args) => runUserHook(processId, 'post-start', ...args);
|
|
59
60
|
const preUninstall = (processId, ...args) => runUserHook(processId, 'pre-uninstall', ...args);
|
|
60
61
|
const preStop = (processId, ...args) => runUserHook(processId, 'pre-stop', ...args);
|
|
61
62
|
|
|
62
|
-
module.exports = { preDeploy, preInstall, postInstall, preStart, preUninstall, preStop, preConfig };
|
|
63
|
+
module.exports = { preDeploy, preInstall, postInstall, preStart, postStart, preUninstall, preStop, preConfig };
|
|
@@ -385,17 +385,22 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
385
385
|
fs.mkdirSync(logsDir, { recursive: true });
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
preStart: (b, { env }) =>
|
|
393
|
-
hooks.preStart(b, {
|
|
388
|
+
const getHookFn =
|
|
389
|
+
(hookName) =>
|
|
390
|
+
(b, { env }) =>
|
|
391
|
+
hooks[hookName](b, {
|
|
394
392
|
appDir: b.env.appDir,
|
|
395
393
|
hooks: Object.assign(b.meta.hooks || {}, b.meta.scripts || {}),
|
|
396
394
|
env,
|
|
397
395
|
did, // root blocklet did,
|
|
398
|
-
})
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
// start process
|
|
399
|
+
const nodeEnvironments = await states.node.getEnvironments();
|
|
400
|
+
await startBlockletProcess(blocklet, {
|
|
401
|
+
...context,
|
|
402
|
+
preStart: getHookFn('preStart'),
|
|
403
|
+
postStart: getHookFn('postStart'),
|
|
399
404
|
nodeEnvironments,
|
|
400
405
|
nodeInfo: await states.node.read(),
|
|
401
406
|
e2eMode,
|
package/lib/util/blocklet.js
CHANGED
|
@@ -76,6 +76,7 @@ const { isBeforeInstalled, expandBundle, findInterfacePortByName, validateBlockl
|
|
|
76
76
|
const getBlockletEngineNameByPlatform = (blockletMeta) => getBlockletEngine(blockletMeta).interpreter;
|
|
77
77
|
|
|
78
78
|
const noop = () => {};
|
|
79
|
+
const noopAsync = async () => {};
|
|
79
80
|
|
|
80
81
|
const statusMap = {
|
|
81
82
|
online: BlockletStatus.running,
|
|
@@ -86,7 +87,7 @@ const statusMap = {
|
|
|
86
87
|
};
|
|
87
88
|
|
|
88
89
|
const PRIVATE_NODE_ENVS = [
|
|
89
|
-
|
|
90
|
+
'NEDB_MULTI_PORT',
|
|
90
91
|
'ABT_NODE_UPDATER_PORT',
|
|
91
92
|
'ABT_NODE_SESSION_TTL',
|
|
92
93
|
'ABT_NODE_ROUTER_PROVIDER',
|
|
@@ -412,7 +413,7 @@ const getHealthyCheckTimeout = (blocklet, { checkHealthImmediately } = {}) => {
|
|
|
412
413
|
*/
|
|
413
414
|
const startBlockletProcess = async (
|
|
414
415
|
blocklet,
|
|
415
|
-
{ preStart = noop, nodeEnvironments, nodeInfo, e2eMode, skippedProcessIds = [] } = {}
|
|
416
|
+
{ preStart = noop, postStart = noopAsync, nodeEnvironments, nodeInfo, e2eMode, skippedProcessIds = [] } = {}
|
|
416
417
|
) => {
|
|
417
418
|
if (!blocklet) {
|
|
418
419
|
throw new Error('blocklet should not be empty');
|
|
@@ -487,8 +488,12 @@ const startBlockletProcess = async (
|
|
|
487
488
|
if (status === BlockletStatus.error) {
|
|
488
489
|
throw new Error(`${processId} is not running within 5 seconds`);
|
|
489
490
|
}
|
|
490
|
-
|
|
491
491
|
logger.info('blocklet started', { processId, status });
|
|
492
|
+
|
|
493
|
+
// run hook
|
|
494
|
+
postStart(b, { env }).catch((err) => {
|
|
495
|
+
logger.error('blocklet post start failed', { processId, error: err });
|
|
496
|
+
});
|
|
492
497
|
},
|
|
493
498
|
{ parallel: true }
|
|
494
499
|
);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.18",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/auth": "1.8.
|
|
23
|
-
"@abtnode/certificate-manager": "1.8.
|
|
24
|
-
"@abtnode/constant": "1.8.
|
|
25
|
-
"@abtnode/cron": "1.8.
|
|
26
|
-
"@abtnode/db": "1.8.
|
|
27
|
-
"@abtnode/logger": "1.8.
|
|
28
|
-
"@abtnode/queue": "1.8.
|
|
29
|
-
"@abtnode/rbac": "1.8.
|
|
30
|
-
"@abtnode/router-provider": "1.8.
|
|
31
|
-
"@abtnode/static-server": "1.8.
|
|
32
|
-
"@abtnode/timemachine": "1.8.
|
|
33
|
-
"@abtnode/util": "1.8.
|
|
22
|
+
"@abtnode/auth": "1.8.18",
|
|
23
|
+
"@abtnode/certificate-manager": "1.8.18",
|
|
24
|
+
"@abtnode/constant": "1.8.18",
|
|
25
|
+
"@abtnode/cron": "1.8.18",
|
|
26
|
+
"@abtnode/db": "1.8.18",
|
|
27
|
+
"@abtnode/logger": "1.8.18",
|
|
28
|
+
"@abtnode/queue": "1.8.18",
|
|
29
|
+
"@abtnode/rbac": "1.8.18",
|
|
30
|
+
"@abtnode/router-provider": "1.8.18",
|
|
31
|
+
"@abtnode/static-server": "1.8.18",
|
|
32
|
+
"@abtnode/timemachine": "1.8.18",
|
|
33
|
+
"@abtnode/util": "1.8.18",
|
|
34
34
|
"@arcblock/did": "1.17.19",
|
|
35
35
|
"@arcblock/did-motif": "^1.1.10",
|
|
36
36
|
"@arcblock/did-util": "1.17.19",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@arcblock/jwt": "^1.17.19",
|
|
39
39
|
"@arcblock/pm2-events": "^0.0.5",
|
|
40
40
|
"@arcblock/vc": "1.17.19",
|
|
41
|
-
"@blocklet/meta": "1.8.
|
|
42
|
-
"@blocklet/sdk": "1.8.
|
|
41
|
+
"@blocklet/meta": "1.8.18",
|
|
42
|
+
"@blocklet/sdk": "1.8.18",
|
|
43
43
|
"@fidm/x509": "^1.2.1",
|
|
44
44
|
"@ocap/mcrypto": "1.17.19",
|
|
45
45
|
"@ocap/util": "1.17.19",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"express": "^4.18.1",
|
|
81
81
|
"jest": "^27.5.1"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "7d82c570913bedf740afca15c27ef10d05aa85fc"
|
|
84
84
|
}
|