@abtnode/core 1.16.54-beta-20251029-055649-a9143beb → 1.16.54-beta-20251030-060219-f2f1ed96
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 +13 -2
- package/lib/blocklet/manager/helper/blue-green-start-blocklet.js +1 -0
- package/lib/blocklet/manager/helper/blue-green-upgrade-blocklet.js +0 -1
- package/lib/blocklet/migration-dist/migration.cjs +1 -1
- package/lib/states/blocklet.js +9 -2
- package/lib/util/blocklet.js +3 -4
- package/lib/util/launcher.js +81 -0
- package/package.json +37 -37
|
@@ -1308,14 +1308,19 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1308
1308
|
await this.checkControllerStatus(blocklet, 'restart');
|
|
1309
1309
|
|
|
1310
1310
|
const result = await states.blocklet.getBlocklet(did);
|
|
1311
|
+
const dids = componentDids?.length
|
|
1312
|
+
? componentDids
|
|
1313
|
+
: result.children
|
|
1314
|
+
.filter((x) => x.status === BlockletStatus.running || x.greenStatus === BlockletStatus.running)
|
|
1315
|
+
.map((x) => x.meta.did);
|
|
1311
1316
|
this.emit(BlockletEvents.statusChange, result);
|
|
1312
1317
|
|
|
1313
1318
|
const ticket = this.startQueue.push({
|
|
1314
1319
|
entity: 'blocklet',
|
|
1315
1320
|
action: 'restart',
|
|
1316
|
-
id: `${did}/${(
|
|
1321
|
+
id: `${did}/${(dids || []).join(',')}`,
|
|
1317
1322
|
did,
|
|
1318
|
-
componentDids,
|
|
1323
|
+
componentDids: dids,
|
|
1319
1324
|
operator,
|
|
1320
1325
|
context,
|
|
1321
1326
|
});
|
|
@@ -2656,6 +2661,12 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
2656
2661
|
options: { runOnInit: false },
|
|
2657
2662
|
fn: () => this.cleanExpiredBlocklets(),
|
|
2658
2663
|
},
|
|
2664
|
+
{
|
|
2665
|
+
name: 'send-serverless-heartbeat',
|
|
2666
|
+
time: process.env.ABT_NODE_SERVERLESS_HEARTBEAT_INTERVAL || '*/5 * * * *', // default every 5 minutes
|
|
2667
|
+
options: { runOnInit: false },
|
|
2668
|
+
fn: () => launcher.sendServerlessHeartbeat(),
|
|
2669
|
+
},
|
|
2659
2670
|
];
|
|
2660
2671
|
|
|
2661
2672
|
logger.info('enable serverless jobs', serverlessJobs.map((x) => x.name).join(','));
|
|
@@ -38983,7 +38983,7 @@ module.exports = require("zlib");
|
|
|
38983
38983
|
/***/ ((module) => {
|
|
38984
38984
|
|
|
38985
38985
|
"use strict";
|
|
38986
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.16.53","description":"","main":"lib/index.js","files":["lib"],"scripts":{"lint":"eslint tests lib --ignore-pattern \'tests/assets/*\'","lint:fix":"eslint --fix tests lib","test":"bun test --bail --timeout 30000","coverage":"bun test --bail --timeout 30000 --coverage"},"keywords":[],"author":"wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)","license":"Apache-2.0","dependencies":{"@abtnode/analytics":"1.16.53","@abtnode/auth":"1.16.53","@abtnode/certificate-manager":"1.16.53","@abtnode/constant":"1.16.53","@abtnode/cron":"1.16.53","@abtnode/db-cache":"1.16.53","@abtnode/docker-utils":"1.16.53","@abtnode/logger":"1.16.53","@abtnode/models":"1.16.53","@abtnode/queue":"1.16.53","@abtnode/rbac":"1.16.53","@abtnode/router-provider":"1.16.53","@abtnode/static-server":"1.16.53","@abtnode/timemachine":"1.16.53","@abtnode/util":"1.16.53","@aigne/aigne-hub":"^0.10.3","@arcblock/did":"^1.
|
|
38986
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.16.53","description":"","main":"lib/index.js","files":["lib"],"scripts":{"lint":"eslint tests lib --ignore-pattern \'tests/assets/*\'","lint:fix":"eslint --fix tests lib","test":"bun test --bail --timeout 30000","coverage":"bun test --bail --timeout 30000 --coverage"},"keywords":[],"author":"wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)","license":"Apache-2.0","dependencies":{"@abtnode/analytics":"1.16.53","@abtnode/auth":"1.16.53","@abtnode/certificate-manager":"1.16.53","@abtnode/constant":"1.16.53","@abtnode/cron":"1.16.53","@abtnode/db-cache":"1.16.53","@abtnode/docker-utils":"1.16.53","@abtnode/logger":"1.16.53","@abtnode/models":"1.16.53","@abtnode/queue":"1.16.53","@abtnode/rbac":"1.16.53","@abtnode/router-provider":"1.16.53","@abtnode/static-server":"1.16.53","@abtnode/timemachine":"1.16.53","@abtnode/util":"1.16.53","@aigne/aigne-hub":"^0.10.3","@arcblock/did":"^1.27.0","@arcblock/did-connect-js":"^1.27.0","@arcblock/did-ext":"^1.27.0","@arcblock/did-motif":"^1.1.14","@arcblock/did-util":"^1.27.0","@arcblock/event-hub":"^1.27.0","@arcblock/jwt":"^1.27.0","@arcblock/pm2-events":"^0.0.5","@arcblock/validator":"^1.27.0","@arcblock/vc":"^1.27.0","@blocklet/constant":"1.16.53","@blocklet/did-space-js":"^1.2.0","@blocklet/env":"1.16.53","@blocklet/error":"^0.2.5","@blocklet/meta":"1.16.53","@blocklet/resolver":"1.16.53","@blocklet/sdk":"1.16.53","@blocklet/server-js":"1.16.53","@blocklet/store":"1.16.53","@blocklet/theme":"^3.1.54","@fidm/x509":"^1.2.1","@ocap/mcrypto":"^1.27.0","@ocap/util":"^1.27.0","@ocap/wallet":"^1.27.0","@slack/webhook":"^5.0.4","archiver":"^7.0.1","axios":"^1.7.9","axon":"^2.0.3","chalk":"^4.1.2","cross-spawn":"^7.0.3","dayjs":"^1.11.13","deep-diff":"^1.0.2","detect-port":"^1.5.1","envfile":"^7.1.0","escape-string-regexp":"^4.0.0","fast-glob":"^3.3.2","filesize":"^10.1.1","flat":"^5.0.2","fs-extra":"^11.2.0","get-port":"^5.1.1","hasha":"^5.2.2","is-base64":"^1.1.0","is-cidr":"4","is-ip":"3","is-url":"^1.2.4","joi":"17.12.2","joi-extension-semver":"^5.0.0","js-yaml":"^4.1.0","kill-port":"^2.0.1","lodash":"^4.17.21","node-stream-zip":"^1.15.0","p-all":"^3.0.0","p-limit":"^3.1.0","p-map":"^4.0.0","p-retry":"^4.6.2","p-wait-for":"^3.2.0","private-ip":"^2.3.4","rate-limiter-flexible":"^5.0.5","read-last-lines":"^1.8.0","semver":"^7.6.3","sequelize":"^6.35.0","shelljs":"^0.8.5","slugify":"^1.6.6","ssri":"^8.0.1","stream-throttle":"^0.1.3","stream-to-promise":"^3.0.0","systeminformation":"^5.23.3","tail":"^2.2.4","tar":"^6.1.11","transliteration":"^2.3.5","ua-parser-js":"^1.0.2","ufo":"^1.5.3","uuid":"^11.1.0","valid-url":"^1.0.9","which":"^2.0.2","xbytes":"^1.8.0"},"devDependencies":{"axios-mock-adapter":"^2.1.0","expand-tilde":"^2.0.2","express":"^4.18.2","unzipper":"^0.10.11"},"gitHead":"e5764f753181ed6a7c615cd4fc6682aacf0cb7cd"}');
|
|
38987
38987
|
|
|
38988
38988
|
/***/ }),
|
|
38989
38989
|
|
package/lib/states/blocklet.js
CHANGED
|
@@ -628,9 +628,16 @@ class BlockletState extends BaseState {
|
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
|
|
631
|
-
setInstalledAt(did) {
|
|
631
|
+
async setInstalledAt(did) {
|
|
632
632
|
logger.info('setInstalledAt', { did });
|
|
633
|
-
|
|
633
|
+
const blocklet = await this.getBlocklet(did);
|
|
634
|
+
if (!blocklet) {
|
|
635
|
+
throw new Error(`Blocklet does not exist: ${did}`);
|
|
636
|
+
}
|
|
637
|
+
if (!blocklet.installedAt) {
|
|
638
|
+
return this.updateBlocklet(did, { installedAt: new Date() });
|
|
639
|
+
}
|
|
640
|
+
return blocklet;
|
|
634
641
|
}
|
|
635
642
|
|
|
636
643
|
async fillChildrenPorts(children, { defaultPort = 0, oldChildren, returnMaxPort } = {}) {
|
package/lib/util/blocklet.js
CHANGED
|
@@ -537,8 +537,8 @@ const getRuntimeEnvironments = (blocklet, nodeEnvironments, ancestors, isGreen =
|
|
|
537
537
|
|
|
538
538
|
// For Access Key authentication, components should use root app's wallet
|
|
539
539
|
// This ensures consistent accessKeyId across parent and child components
|
|
540
|
-
const
|
|
541
|
-
? getBlockletWallet(root.
|
|
540
|
+
const accessWallet = get(nodeEnvironments, 'ABT_NODE_SK')
|
|
541
|
+
? getBlockletWallet(root.appDid || root.meta.did, nodeEnvironments.ABT_NODE_SK, undefined, 2)
|
|
542
542
|
: null;
|
|
543
543
|
|
|
544
544
|
const BLOCKLET_APP_IDS = getBlockletAppIdList(root).join(',');
|
|
@@ -567,10 +567,9 @@ const getRuntimeEnvironments = (blocklet, nodeEnvironments, ancestors, isGreen =
|
|
|
567
567
|
BLOCKLET_APP_VERSION: root.meta.version,
|
|
568
568
|
BLOCKLET_APP_IDS,
|
|
569
569
|
BLOCKLET_COMPONENT_API_KEY: componentApiKey,
|
|
570
|
+
BLOCKLET_APP_ASK: accessWallet?.secretKey,
|
|
570
571
|
...nodeEnvironments,
|
|
571
572
|
...safeNodeEnvironments,
|
|
572
|
-
// compatible with previous version
|
|
573
|
-
...(process.env.WITH_SK ? {} : { BLOCKLET_APP_ASK: accessKeyWallet?.secretKey }),
|
|
574
573
|
};
|
|
575
574
|
|
|
576
575
|
const aigne = get(root, 'settings.aigne', {});
|
package/lib/util/launcher.js
CHANGED
|
@@ -7,6 +7,7 @@ const pick = require('lodash/pick');
|
|
|
7
7
|
const uniq = require('lodash/uniq');
|
|
8
8
|
const trim = require('lodash/trim');
|
|
9
9
|
const merge = require('lodash/merge');
|
|
10
|
+
const si = require('systeminformation');
|
|
10
11
|
const isEmpty = require('lodash/isEmpty');
|
|
11
12
|
const {
|
|
12
13
|
getUserAvatarUrl,
|
|
@@ -156,6 +157,85 @@ const notifyBlockletUpdated = (blocklet) => notifyLauncher('serverless.blocklet.
|
|
|
156
157
|
const notifyBlockletStarted = (blocklet) => notifyLauncher('serverless.blocklet.started', blocklet);
|
|
157
158
|
const notifyBlockletStopped = (blocklet) => notifyLauncher('serverless.blocklet.stopped', blocklet);
|
|
158
159
|
|
|
160
|
+
const getCpuUtilization = async () => {
|
|
161
|
+
const load = await si.currentLoad();
|
|
162
|
+
const u = Number(load?.currentLoad);
|
|
163
|
+
|
|
164
|
+
return Math.max(0, Math.min(1, u / 100));
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const getComponentsAggregate = async () => {
|
|
168
|
+
try {
|
|
169
|
+
const list = await states.blocklet.getBlocklets();
|
|
170
|
+
const counts = {};
|
|
171
|
+
let total = 0;
|
|
172
|
+
list.forEach((b) => {
|
|
173
|
+
const children = Array.isArray(b.children) ? b.children : [];
|
|
174
|
+
children.forEach((child) => {
|
|
175
|
+
const key = fromBlockletStatus(child.status) || 'unknown';
|
|
176
|
+
counts[key] = (counts[key] || 0) + 1;
|
|
177
|
+
total += 1;
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
return { total, counts };
|
|
182
|
+
} catch (error) {
|
|
183
|
+
logger.error('getComponentsAggregate failed', { error });
|
|
184
|
+
return { total: 0, counts: {} };
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const sendServerlessHeartbeat = async () => {
|
|
189
|
+
logger.info('send serverless heartbeat');
|
|
190
|
+
const nodeInfo = await states.node.read();
|
|
191
|
+
const launcherUrl = nodeInfo?.launcher?.url;
|
|
192
|
+
if (!launcherUrl) {
|
|
193
|
+
logger.error('skip heartbeat: launcher url not configured', {
|
|
194
|
+
launcher: nodeInfo?.launcher,
|
|
195
|
+
});
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const { did } = nodeInfo;
|
|
200
|
+
const cpuCores = os.cpus().length;
|
|
201
|
+
const [mem, cpuUtilization, components] = await Promise.all([
|
|
202
|
+
si.mem(),
|
|
203
|
+
getCpuUtilization(),
|
|
204
|
+
getComponentsAggregate(),
|
|
205
|
+
]);
|
|
206
|
+
|
|
207
|
+
const memoryAvailableMb = mem.available / 1024 / 1024;
|
|
208
|
+
const memoryTotalMb = mem.total / 1024 / 1024;
|
|
209
|
+
|
|
210
|
+
const payload = {
|
|
211
|
+
name: nodeInfo.name,
|
|
212
|
+
description: nodeInfo.description,
|
|
213
|
+
version,
|
|
214
|
+
did,
|
|
215
|
+
cpuUtilization,
|
|
216
|
+
memoryAvailableMb,
|
|
217
|
+
memoryTotalMb,
|
|
218
|
+
cpuCores,
|
|
219
|
+
components,
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
logger.debug('send serverless heartbeat payload', { did, launcherUrl, payload });
|
|
223
|
+
|
|
224
|
+
try {
|
|
225
|
+
const result = await doRequest(nodeInfo.sk, {
|
|
226
|
+
launcherUrl,
|
|
227
|
+
pathname: '/api/serverless/heartbeat',
|
|
228
|
+
payload,
|
|
229
|
+
method: 'post',
|
|
230
|
+
});
|
|
231
|
+
logger.info('sent heartbeat to launcher', { did, launcherUrl, result });
|
|
232
|
+
return result;
|
|
233
|
+
} catch (error) {
|
|
234
|
+
logger.error('send heartbeat failed', { error: error.message, did, launcherUrl });
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
159
239
|
const consumeLauncherSession = async ({ params, blocklet }) => {
|
|
160
240
|
try {
|
|
161
241
|
const info = await states.node.read();
|
|
@@ -657,4 +737,5 @@ module.exports = {
|
|
|
657
737
|
notifyBlockletStopped,
|
|
658
738
|
launchBlockletByLauncher,
|
|
659
739
|
launchBlockletWithoutWallet,
|
|
740
|
+
sendServerlessHeartbeat,
|
|
660
741
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.54-beta-
|
|
6
|
+
"version": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,46 +19,46 @@
|
|
|
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.54-beta-
|
|
23
|
-
"@abtnode/auth": "1.16.54-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.54-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.54-beta-
|
|
26
|
-
"@abtnode/cron": "1.16.54-beta-
|
|
27
|
-
"@abtnode/db-cache": "1.16.54-beta-
|
|
28
|
-
"@abtnode/docker-utils": "1.16.54-beta-
|
|
29
|
-
"@abtnode/logger": "1.16.54-beta-
|
|
30
|
-
"@abtnode/models": "1.16.54-beta-
|
|
31
|
-
"@abtnode/queue": "1.16.54-beta-
|
|
32
|
-
"@abtnode/rbac": "1.16.54-beta-
|
|
33
|
-
"@abtnode/router-provider": "1.16.54-beta-
|
|
34
|
-
"@abtnode/static-server": "1.16.54-beta-
|
|
35
|
-
"@abtnode/timemachine": "1.16.54-beta-
|
|
36
|
-
"@abtnode/util": "1.16.54-beta-
|
|
22
|
+
"@abtnode/analytics": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
23
|
+
"@abtnode/auth": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
25
|
+
"@abtnode/constant": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
26
|
+
"@abtnode/cron": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
27
|
+
"@abtnode/db-cache": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
28
|
+
"@abtnode/docker-utils": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
29
|
+
"@abtnode/logger": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
30
|
+
"@abtnode/models": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
31
|
+
"@abtnode/queue": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
32
|
+
"@abtnode/rbac": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
33
|
+
"@abtnode/router-provider": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
34
|
+
"@abtnode/static-server": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
35
|
+
"@abtnode/timemachine": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
36
|
+
"@abtnode/util": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
37
37
|
"@aigne/aigne-hub": "^0.10.3",
|
|
38
|
-
"@arcblock/did": "^1.
|
|
39
|
-
"@arcblock/did-connect-js": "^1.
|
|
40
|
-
"@arcblock/did-ext": "^1.
|
|
38
|
+
"@arcblock/did": "^1.27.0",
|
|
39
|
+
"@arcblock/did-connect-js": "^1.27.0",
|
|
40
|
+
"@arcblock/did-ext": "^1.27.0",
|
|
41
41
|
"@arcblock/did-motif": "^1.1.14",
|
|
42
|
-
"@arcblock/did-util": "^1.
|
|
43
|
-
"@arcblock/event-hub": "^1.
|
|
44
|
-
"@arcblock/jwt": "^1.
|
|
42
|
+
"@arcblock/did-util": "^1.27.0",
|
|
43
|
+
"@arcblock/event-hub": "^1.27.0",
|
|
44
|
+
"@arcblock/jwt": "^1.27.0",
|
|
45
45
|
"@arcblock/pm2-events": "^0.0.5",
|
|
46
|
-
"@arcblock/validator": "^1.
|
|
47
|
-
"@arcblock/vc": "^1.
|
|
48
|
-
"@blocklet/constant": "1.16.54-beta-
|
|
49
|
-
"@blocklet/did-space-js": "^1.
|
|
50
|
-
"@blocklet/env": "1.16.54-beta-
|
|
46
|
+
"@arcblock/validator": "^1.27.0",
|
|
47
|
+
"@arcblock/vc": "^1.27.0",
|
|
48
|
+
"@blocklet/constant": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
49
|
+
"@blocklet/did-space-js": "^1.2.0",
|
|
50
|
+
"@blocklet/env": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
51
51
|
"@blocklet/error": "^0.2.5",
|
|
52
|
-
"@blocklet/meta": "1.16.54-beta-
|
|
53
|
-
"@blocklet/resolver": "1.16.54-beta-
|
|
54
|
-
"@blocklet/sdk": "1.16.54-beta-
|
|
55
|
-
"@blocklet/server-js": "1.16.54-beta-
|
|
56
|
-
"@blocklet/store": "1.16.54-beta-
|
|
57
|
-
"@blocklet/theme": "^3.1.
|
|
52
|
+
"@blocklet/meta": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
53
|
+
"@blocklet/resolver": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
54
|
+
"@blocklet/sdk": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
55
|
+
"@blocklet/server-js": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
56
|
+
"@blocklet/store": "1.16.54-beta-20251030-060219-f2f1ed96",
|
|
57
|
+
"@blocklet/theme": "^3.1.54",
|
|
58
58
|
"@fidm/x509": "^1.2.1",
|
|
59
|
-
"@ocap/mcrypto": "^1.
|
|
60
|
-
"@ocap/util": "^1.
|
|
61
|
-
"@ocap/wallet": "^1.
|
|
59
|
+
"@ocap/mcrypto": "^1.27.0",
|
|
60
|
+
"@ocap/util": "^1.27.0",
|
|
61
|
+
"@ocap/wallet": "^1.27.0",
|
|
62
62
|
"@slack/webhook": "^5.0.4",
|
|
63
63
|
"archiver": "^7.0.1",
|
|
64
64
|
"axios": "^1.7.9",
|
|
@@ -118,5 +118,5 @@
|
|
|
118
118
|
"express": "^4.18.2",
|
|
119
119
|
"unzipper": "^0.10.11"
|
|
120
120
|
},
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "a4182e02a693b097c76b6a9907a8a1d4816ee914"
|
|
122
122
|
}
|