@abtnode/core 1.16.45-beta-20250627-075343-5af3ad9a → 1.16.45-beta-20250630-024910-24ef8c24
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.
|
@@ -10,7 +10,7 @@ const { BlockletStatus } = require('@blocklet/constant');
|
|
|
10
10
|
const defaultLogger = require('@abtnode/logger')('blocklet-runtime-monitor');
|
|
11
11
|
|
|
12
12
|
const { Op } = require('sequelize');
|
|
13
|
-
const { getRuntimeInfo } = require('../util/blocklet');
|
|
13
|
+
const { getRuntimeInfo, getDockerRuntimeInfoByDockerName } = require('../util/blocklet');
|
|
14
14
|
|
|
15
15
|
// type BlockletHistoryItem = {
|
|
16
16
|
// date: number;
|
|
@@ -139,8 +139,10 @@ class BlockletRuntimeMonitor extends EventEmitter {
|
|
|
139
139
|
const processId = getComponentProcessId(component, ancestors);
|
|
140
140
|
try {
|
|
141
141
|
const runtimeInfo = await getRuntimeInfo(processId);
|
|
142
|
+
const dockerName = component.environments?.find((x) => x.key === 'BLOCKLET_DOCKER_NAME')?.value;
|
|
143
|
+
const dockerRuntimeInfo = dockerName ? await getDockerRuntimeInfoByDockerName(dockerName) : {};
|
|
142
144
|
|
|
143
|
-
this.data[blockletDid][componentId] = { runtimeInfo };
|
|
145
|
+
this.data[blockletDid][componentId] = { runtimeInfo: { ...runtimeInfo, ...dockerRuntimeInfo } };
|
|
144
146
|
|
|
145
147
|
if (!component.mountPoint || component.mountPoint === '/') {
|
|
146
148
|
this.data[blockletDid].app.runtimeInfo = cloneDeep(runtimeInfo);
|
|
@@ -150,6 +152,7 @@ class BlockletRuntimeMonitor extends EventEmitter {
|
|
|
150
152
|
appMem += runtimeInfo.memoryUsage || 0;
|
|
151
153
|
runningDocker = runningDocker || runtimeInfo.runningDocker;
|
|
152
154
|
} catch (err) {
|
|
155
|
+
console.error(err);
|
|
153
156
|
// component status in db may not sync with pm2 when server has just started
|
|
154
157
|
if (err.code !== 'BLOCKLET_PROCESS_404') {
|
|
155
158
|
this.logger.error('failed to get blocklet runtime info', { processId, error: err });
|
|
@@ -238,7 +241,16 @@ class BlockletRuntimeMonitor extends EventEmitter {
|
|
|
238
241
|
}
|
|
239
242
|
|
|
240
243
|
_push(blockletDid, value) {
|
|
241
|
-
return this.states.runtimeInsight.insert({ did: blockletDid, ...value })
|
|
244
|
+
return this.states.runtimeInsight.insert({ did: blockletDid, ...value }).catch((err) => {
|
|
245
|
+
if (err.name === 'SequelizeValidationError') {
|
|
246
|
+
console.error(
|
|
247
|
+
'RuntimeInsight validation error',
|
|
248
|
+
err.errors.map((e) => e.message)
|
|
249
|
+
);
|
|
250
|
+
} else {
|
|
251
|
+
console.error('RuntimeInsight insert error', err);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
242
254
|
}
|
|
243
255
|
}
|
|
244
256
|
|
|
@@ -254,7 +254,16 @@ class NodeRuntimeMonitor extends EventEmitter {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
_push(value) {
|
|
257
|
-
return this.state.insert({ did: this.did, ...value })
|
|
257
|
+
return this.state.insert({ did: this.did, ...value }).catch((err) => {
|
|
258
|
+
if (err.name === 'SequelizeValidationError') {
|
|
259
|
+
console.error(
|
|
260
|
+
'RuntimeInsight validation error',
|
|
261
|
+
err.errors.map((e) => e.message)
|
|
262
|
+
);
|
|
263
|
+
} else {
|
|
264
|
+
console.error('RuntimeInsight insert error', err);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
258
267
|
}
|
|
259
268
|
}
|
|
260
269
|
|
package/lib/util/blocklet.js
CHANGED
|
@@ -114,6 +114,7 @@ const md5 = require('@abtnode/util/lib/md5');
|
|
|
114
114
|
|
|
115
115
|
const promiseSpawn = require('@abtnode/util/lib/promise-spawn');
|
|
116
116
|
const { getAbtNodeRedisAndSQLiteUrl } = require('@abtnode/db-cache');
|
|
117
|
+
const xbytes = require('xbytes');
|
|
117
118
|
const { validate: validateEngine, get: getEngine } = require('../blocklet/manager/engine');
|
|
118
119
|
|
|
119
120
|
const isRequirementsSatisfied = require('./requirement');
|
|
@@ -1320,6 +1321,26 @@ const getRuntimeInfo = async (processId) => {
|
|
|
1320
1321
|
};
|
|
1321
1322
|
};
|
|
1322
1323
|
|
|
1324
|
+
/**
|
|
1325
|
+
*
|
|
1326
|
+
*
|
|
1327
|
+
* @param {string} dockerName
|
|
1328
|
+
* @return {Promise<{ memoryUsage?: number }>}
|
|
1329
|
+
*/
|
|
1330
|
+
const getDockerRuntimeInfoByDockerName = async (dockerName) => {
|
|
1331
|
+
try {
|
|
1332
|
+
const proc = await promiseSpawn(`docker stats --no-stream --format "{{json .}}" ${dockerName}`, { mute: true });
|
|
1333
|
+
const stats = JSON.parse(proc);
|
|
1334
|
+
return {
|
|
1335
|
+
cpuUsage: stats.CPUPerc ? parseFloat(stats.CPUPerc.replace('%', '').trim()) : 0,
|
|
1336
|
+
memoryUsage: stats.MemUsage ? xbytes.parseSize(stats.MemUsage.split('/')[0].trim()) : 0,
|
|
1337
|
+
};
|
|
1338
|
+
} catch (error) {
|
|
1339
|
+
logger.error('Get docker runtime info by docker name failed', { dockerName, error });
|
|
1340
|
+
return {};
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
|
|
1323
1344
|
/**
|
|
1324
1345
|
* merge services
|
|
1325
1346
|
* from meta.children[].mountPoints[].services, meta.children[].services
|
|
@@ -2497,6 +2518,7 @@ module.exports = {
|
|
|
2497
2518
|
pruneBlockletBundle,
|
|
2498
2519
|
getDiskInfo,
|
|
2499
2520
|
getRuntimeInfo,
|
|
2521
|
+
getDockerRuntimeInfoByDockerName,
|
|
2500
2522
|
mergeMeta,
|
|
2501
2523
|
getUpdateMetaList,
|
|
2502
2524
|
getTypeFromInstallParams,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.45-beta-
|
|
6
|
+
"version": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,22 +19,22 @@
|
|
|
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.45-beta-
|
|
23
|
-
"@abtnode/auth": "1.16.45-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.45-beta-
|
|
25
|
-
"@abtnode/client": "1.16.45-beta-
|
|
26
|
-
"@abtnode/constant": "1.16.45-beta-
|
|
27
|
-
"@abtnode/cron": "1.16.45-beta-
|
|
28
|
-
"@abtnode/db-cache": "1.16.45-beta-
|
|
29
|
-
"@abtnode/docker-utils": "1.16.45-beta-
|
|
30
|
-
"@abtnode/logger": "1.16.45-beta-
|
|
31
|
-
"@abtnode/models": "1.16.45-beta-
|
|
32
|
-
"@abtnode/queue": "1.16.45-beta-
|
|
33
|
-
"@abtnode/rbac": "1.16.45-beta-
|
|
34
|
-
"@abtnode/router-provider": "1.16.45-beta-
|
|
35
|
-
"@abtnode/static-server": "1.16.45-beta-
|
|
36
|
-
"@abtnode/timemachine": "1.16.45-beta-
|
|
37
|
-
"@abtnode/util": "1.16.45-beta-
|
|
22
|
+
"@abtnode/analytics": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
23
|
+
"@abtnode/auth": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
25
|
+
"@abtnode/client": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
26
|
+
"@abtnode/constant": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
27
|
+
"@abtnode/cron": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
28
|
+
"@abtnode/db-cache": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
29
|
+
"@abtnode/docker-utils": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
30
|
+
"@abtnode/logger": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
31
|
+
"@abtnode/models": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
32
|
+
"@abtnode/queue": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
33
|
+
"@abtnode/rbac": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
34
|
+
"@abtnode/router-provider": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
35
|
+
"@abtnode/static-server": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
36
|
+
"@abtnode/timemachine": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
37
|
+
"@abtnode/util": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
38
38
|
"@arcblock/did": "1.20.14",
|
|
39
39
|
"@arcblock/did-auth": "1.20.14",
|
|
40
40
|
"@arcblock/did-ext": "1.20.14",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"@arcblock/pm2-events": "^0.0.5",
|
|
46
46
|
"@arcblock/validator": "1.20.14",
|
|
47
47
|
"@arcblock/vc": "1.20.14",
|
|
48
|
-
"@blocklet/constant": "1.16.45-beta-
|
|
48
|
+
"@blocklet/constant": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
49
49
|
"@blocklet/did-space-js": "^1.0.62",
|
|
50
|
-
"@blocklet/env": "1.16.45-beta-
|
|
50
|
+
"@blocklet/env": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
51
51
|
"@blocklet/error": "^0.2.5",
|
|
52
|
-
"@blocklet/meta": "1.16.45-beta-
|
|
53
|
-
"@blocklet/resolver": "1.16.45-beta-
|
|
54
|
-
"@blocklet/sdk": "1.16.45-beta-
|
|
55
|
-
"@blocklet/store": "1.16.45-beta-
|
|
52
|
+
"@blocklet/meta": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
53
|
+
"@blocklet/resolver": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
54
|
+
"@blocklet/sdk": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
55
|
+
"@blocklet/store": "1.16.45-beta-20250630-024910-24ef8c24",
|
|
56
56
|
"@blocklet/theme": "^2.13.70",
|
|
57
57
|
"@fidm/x509": "^1.2.1",
|
|
58
58
|
"@ocap/mcrypto": "1.20.14",
|
|
@@ -116,5 +116,5 @@
|
|
|
116
116
|
"jest": "^29.7.0",
|
|
117
117
|
"unzipper": "^0.10.11"
|
|
118
118
|
},
|
|
119
|
-
"gitHead": "
|
|
119
|
+
"gitHead": "a619af43bcf85d6d0c9fcba96c4fa1f04d4b80c4"
|
|
120
120
|
}
|