@blocklet/cli 1.17.4-beta-20251204-080001-08643fbe → 1.17.4-beta-20251205-104405-28838df1
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/commands/server/stop.js +71 -1
- package/lib/process/daemon.js +1 -1
- package/package.json +17 -17
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-await-in-loop */
|
|
1
2
|
const chalk = require('chalk');
|
|
2
3
|
const capitalize = require('lodash/capitalize');
|
|
3
4
|
|
|
@@ -34,6 +35,60 @@ const { checkRunning } = require('../../manager');
|
|
|
34
35
|
const { wrapSpinner } = require('../../ui');
|
|
35
36
|
const clearAllCache = require('../../util/clear-all-cache');
|
|
36
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Update all running/starting blocklets status to waiting
|
|
40
|
+
* @param {Object} node - The node instance
|
|
41
|
+
*/
|
|
42
|
+
const updateRunningBlockletsToWaiting = async (node) => {
|
|
43
|
+
try {
|
|
44
|
+
const blocklets = await node.getBlocklets({ includeRuntimeInfo: false });
|
|
45
|
+
|
|
46
|
+
for (const blocklet of blocklets) {
|
|
47
|
+
const { did } = blocklet.meta;
|
|
48
|
+
const componentDids = [];
|
|
49
|
+
|
|
50
|
+
const needChangeToWaiting = [
|
|
51
|
+
BlockletStatus.running,
|
|
52
|
+
BlockletStatus.waiting,
|
|
53
|
+
BlockletStatus.starting,
|
|
54
|
+
BlockletStatus.restarting,
|
|
55
|
+
BlockletStatus.downloading,
|
|
56
|
+
BlockletStatus.starting,
|
|
57
|
+
];
|
|
58
|
+
// Check children components
|
|
59
|
+
if (blocklet.children && blocklet.children.length > 0) {
|
|
60
|
+
for (const child of blocklet.children) {
|
|
61
|
+
if (needChangeToWaiting.includes(child.status) || needChangeToWaiting.includes(child.greenStatus)) {
|
|
62
|
+
componentDids.push(child.meta.did);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Update status to waiting if needed
|
|
68
|
+
if (componentDids.length > 0) {
|
|
69
|
+
try {
|
|
70
|
+
await node.setBlockletStatus(did, BlockletStatus.waiting, {
|
|
71
|
+
componentDids,
|
|
72
|
+
operator: 'daemon',
|
|
73
|
+
});
|
|
74
|
+
await node.setBlockletStatus(did, BlockletStatus.stopped, {
|
|
75
|
+
componentDids,
|
|
76
|
+
operator: 'daemon',
|
|
77
|
+
isGreen: true,
|
|
78
|
+
});
|
|
79
|
+
} catch (err) {
|
|
80
|
+
printError(`Failed to update blocklet status to waiting for ${did}:`, err.message);
|
|
81
|
+
// 错误被忽略,不阻止其他 blocklet 的处理
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} catch (err) {
|
|
86
|
+
// 即使获取 blocklets 失败,也不应该阻止 stop 流程
|
|
87
|
+
// 错误被忽略,让 stop 流程继续
|
|
88
|
+
printError('Failed to update blocklet statuses to waiting:', err.message);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
37
92
|
const forceStopServer = async () => {
|
|
38
93
|
const stop = async () => {
|
|
39
94
|
try {
|
|
@@ -48,6 +103,14 @@ const forceStopServer = async () => {
|
|
|
48
103
|
printSuccess(`${capitalize(clearedProvider)} router is stopped successfully`);
|
|
49
104
|
}
|
|
50
105
|
|
|
106
|
+
try {
|
|
107
|
+
const { node } = await getNode({ dir: process.cwd() });
|
|
108
|
+
await updateRunningBlockletsToWaiting(node);
|
|
109
|
+
printSuccess('All blocklet processes stopped successfully');
|
|
110
|
+
} catch (error) {
|
|
111
|
+
printError(`Failed to update blocklet statuses to waiting: ${error.message}`);
|
|
112
|
+
}
|
|
113
|
+
|
|
51
114
|
// Kill all blocklet processes
|
|
52
115
|
try {
|
|
53
116
|
const list = await pm2.listAsync();
|
|
@@ -58,7 +121,6 @@ const forceStopServer = async () => {
|
|
|
58
121
|
blockletProcesses.map((process) => () => pm2.deleteAsync(process.name)),
|
|
59
122
|
{ concurrency: 6 }
|
|
60
123
|
);
|
|
61
|
-
printSuccess('All blocklet processes stopped successfully');
|
|
62
124
|
} catch (error) {
|
|
63
125
|
printError(`Failed to stop blocklet processes: ${error.message}`);
|
|
64
126
|
}
|
|
@@ -157,6 +219,14 @@ exports.run = async ({ force = false }) => {
|
|
|
157
219
|
}
|
|
158
220
|
}
|
|
159
221
|
|
|
222
|
+
// Update all running/starting blocklets status to waiting
|
|
223
|
+
// Re-fetch blocklets to get current state after stopping
|
|
224
|
+
try {
|
|
225
|
+
await updateRunningBlockletsToWaiting(node);
|
|
226
|
+
} catch (err) {
|
|
227
|
+
printError('Failed to update blocklet statuses to waiting:', err.message);
|
|
228
|
+
}
|
|
229
|
+
|
|
160
230
|
const actions = [
|
|
161
231
|
{ action: 'kill', processName: PROCESS_NAME_DAEMON },
|
|
162
232
|
{ action: 'kill', processName: PROCESS_NAME_SERVICE },
|
package/lib/process/daemon.js
CHANGED
|
@@ -34,7 +34,7 @@ const { SERVER_STATUS } = require('@abtnode/constant');
|
|
|
34
34
|
const createServer = require('@abtnode/webapp/blocklet'); // eslint-disable-line
|
|
35
35
|
|
|
36
36
|
const { setupGracefulShutdown } = require('@abtnode/util/lib/pm2/setup-graceful-shutdown');
|
|
37
|
-
const ensureBlockletRunning = require('@abtnode/core/lib/blocklet/manager/ensure-blocklet-running');
|
|
37
|
+
const { ensureBlockletRunning } = require('@abtnode/core/lib/blocklet/manager/ensure-blocklet-running');
|
|
38
38
|
|
|
39
39
|
const wallet = getNodeWallet(process.env.ABT_NODE_SK);
|
|
40
40
|
const dataDir = process.env.ABT_NODE_DATA_DIR;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/cli",
|
|
3
|
-
"version": "1.17.4-beta-
|
|
3
|
+
"version": "1.17.4-beta-20251205-104405-28838df1",
|
|
4
4
|
"description": "Command line tools to manage Blocklet Server",
|
|
5
5
|
"homepage": "https://www.arcblock.io/docs/blocklet-cli",
|
|
6
6
|
"bin": {
|
|
@@ -33,28 +33,28 @@
|
|
|
33
33
|
"url": "https://github.com/ArcBlock/blocklet-server/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@abtnode/blocklet-services": "1.17.4-beta-
|
|
37
|
-
"@abtnode/constant": "1.17.4-beta-
|
|
38
|
-
"@abtnode/core": "1.17.4-beta-
|
|
39
|
-
"@abtnode/db-cache": "1.17.4-beta-
|
|
40
|
-
"@abtnode/logger": "1.17.4-beta-
|
|
41
|
-
"@abtnode/models": "1.17.4-beta-
|
|
42
|
-
"@abtnode/router-provider": "1.17.4-beta-
|
|
43
|
-
"@abtnode/util": "1.17.4-beta-
|
|
44
|
-
"@abtnode/webapp": "1.17.4-beta-
|
|
36
|
+
"@abtnode/blocklet-services": "1.17.4-beta-20251205-104405-28838df1",
|
|
37
|
+
"@abtnode/constant": "1.17.4-beta-20251205-104405-28838df1",
|
|
38
|
+
"@abtnode/core": "1.17.4-beta-20251205-104405-28838df1",
|
|
39
|
+
"@abtnode/db-cache": "1.17.4-beta-20251205-104405-28838df1",
|
|
40
|
+
"@abtnode/logger": "1.17.4-beta-20251205-104405-28838df1",
|
|
41
|
+
"@abtnode/models": "1.17.4-beta-20251205-104405-28838df1",
|
|
42
|
+
"@abtnode/router-provider": "1.17.4-beta-20251205-104405-28838df1",
|
|
43
|
+
"@abtnode/util": "1.17.4-beta-20251205-104405-28838df1",
|
|
44
|
+
"@abtnode/webapp": "1.17.4-beta-20251205-104405-28838df1",
|
|
45
45
|
"@arcblock/did": "^1.27.12",
|
|
46
46
|
"@arcblock/event-hub": "^1.27.12",
|
|
47
47
|
"@arcblock/ipfs-only-hash": "^0.0.2",
|
|
48
48
|
"@arcblock/jwt": "^1.27.12",
|
|
49
49
|
"@arcblock/ws": "^1.27.12",
|
|
50
|
-
"@blocklet/constant": "1.17.4-beta-
|
|
50
|
+
"@blocklet/constant": "1.17.4-beta-20251205-104405-28838df1",
|
|
51
51
|
"@blocklet/error": "^0.3.3",
|
|
52
52
|
"@blocklet/form-collector": "^0.1.8",
|
|
53
|
-
"@blocklet/images": "1.17.4-beta-
|
|
54
|
-
"@blocklet/meta": "1.17.4-beta-
|
|
55
|
-
"@blocklet/resolver": "1.17.4-beta-
|
|
56
|
-
"@blocklet/server-js": "1.17.4-beta-
|
|
57
|
-
"@blocklet/store": "1.17.4-beta-
|
|
53
|
+
"@blocklet/images": "1.17.4-beta-20251205-104405-28838df1",
|
|
54
|
+
"@blocklet/meta": "1.17.4-beta-20251205-104405-28838df1",
|
|
55
|
+
"@blocklet/resolver": "1.17.4-beta-20251205-104405-28838df1",
|
|
56
|
+
"@blocklet/server-js": "1.17.4-beta-20251205-104405-28838df1",
|
|
57
|
+
"@blocklet/store": "1.17.4-beta-20251205-104405-28838df1",
|
|
58
58
|
"@blocklet/theme-builder": "^0.4.8",
|
|
59
59
|
"@ocap/client": "^1.27.12",
|
|
60
60
|
"@ocap/mcrypto": "^1.27.12",
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
"engines": {
|
|
154
154
|
"node": ">=14"
|
|
155
155
|
},
|
|
156
|
-
"gitHead": "
|
|
156
|
+
"gitHead": "f8e18c8b32b19fd98de3d292a0036e628e59d474",
|
|
157
157
|
"devDependencies": {
|
|
158
158
|
"@types/fs-extra": "^11.0.4"
|
|
159
159
|
}
|