@blocklet/cli 1.16.54-beta-20251024-030947-6f2889bf → 1.16.54-beta-20251027-105624-dfa978f8

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.
@@ -73,6 +73,7 @@ const forceStopServer = async () => {
73
73
  }
74
74
  } catch (error) {
75
75
  printError(`Blocklet Server related processes stop failed: ${error.message}`);
76
+ throw error;
76
77
  }
77
78
  };
78
79
  const timeout = 20; // 20 seconds
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/cli",
3
- "version": "1.16.54-beta-20251024-030947-6f2889bf",
3
+ "version": "1.16.54-beta-20251027-105624-dfa978f8",
4
4
  "description": "Command line tools to manage Blocklet Server",
5
5
  "homepage": "https://www.arcblock.io/docs/blocklet-cli",
6
6
  "bin": {
@@ -12,8 +12,8 @@
12
12
  "scripts": {
13
13
  "lint": "eslint lib bin",
14
14
  "lint:fix": "eslint lib bin --fix",
15
- "test": "bun test",
16
- "coverage": "bun test --coverage",
15
+ "test": "bun test --bail --timeout 30000",
16
+ "coverage": "bun test --bail --timeout 30000 --coverage",
17
17
  "postinstall": "node lib/postinstall.js"
18
18
  },
19
19
  "files": [
@@ -35,28 +35,28 @@
35
35
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
36
36
  },
37
37
  "dependencies": {
38
- "@abtnode/blocklet-services": "1.16.54-beta-20251024-030947-6f2889bf",
39
- "@abtnode/constant": "1.16.54-beta-20251024-030947-6f2889bf",
40
- "@abtnode/core": "1.16.54-beta-20251024-030947-6f2889bf",
41
- "@abtnode/db-cache": "1.16.54-beta-20251024-030947-6f2889bf",
42
- "@abtnode/logger": "1.16.54-beta-20251024-030947-6f2889bf",
43
- "@abtnode/models": "1.16.54-beta-20251024-030947-6f2889bf",
44
- "@abtnode/router-provider": "1.16.54-beta-20251024-030947-6f2889bf",
45
- "@abtnode/util": "1.16.54-beta-20251024-030947-6f2889bf",
46
- "@abtnode/webapp": "1.16.54-beta-20251024-030947-6f2889bf",
38
+ "@abtnode/blocklet-services": "1.16.54-beta-20251027-105624-dfa978f8",
39
+ "@abtnode/constant": "1.16.54-beta-20251027-105624-dfa978f8",
40
+ "@abtnode/core": "1.16.54-beta-20251027-105624-dfa978f8",
41
+ "@abtnode/db-cache": "1.16.54-beta-20251027-105624-dfa978f8",
42
+ "@abtnode/logger": "1.16.54-beta-20251027-105624-dfa978f8",
43
+ "@abtnode/models": "1.16.54-beta-20251027-105624-dfa978f8",
44
+ "@abtnode/router-provider": "1.16.54-beta-20251027-105624-dfa978f8",
45
+ "@abtnode/util": "1.16.54-beta-20251027-105624-dfa978f8",
46
+ "@abtnode/webapp": "1.16.54-beta-20251027-105624-dfa978f8",
47
47
  "@arcblock/did": "^1.26.3",
48
48
  "@arcblock/event-hub": "^1.26.3",
49
49
  "@arcblock/ipfs-only-hash": "^0.0.2",
50
50
  "@arcblock/jwt": "^1.26.3",
51
51
  "@arcblock/ws": "^1.26.3",
52
- "@blocklet/constant": "1.16.54-beta-20251024-030947-6f2889bf",
52
+ "@blocklet/constant": "1.16.54-beta-20251027-105624-dfa978f8",
53
53
  "@blocklet/error": "^0.2.5",
54
54
  "@blocklet/form-collector": "^0.1.8",
55
- "@blocklet/images": "1.16.54-beta-20251024-030947-6f2889bf",
56
- "@blocklet/meta": "1.16.54-beta-20251024-030947-6f2889bf",
57
- "@blocklet/resolver": "1.16.54-beta-20251024-030947-6f2889bf",
58
- "@blocklet/server-js": "1.16.54-beta-20251024-030947-6f2889bf",
59
- "@blocklet/store": "1.16.54-beta-20251024-030947-6f2889bf",
55
+ "@blocklet/images": "1.16.54-beta-20251027-105624-dfa978f8",
56
+ "@blocklet/meta": "1.16.54-beta-20251027-105624-dfa978f8",
57
+ "@blocklet/resolver": "1.16.54-beta-20251027-105624-dfa978f8",
58
+ "@blocklet/server-js": "1.16.54-beta-20251027-105624-dfa978f8",
59
+ "@blocklet/store": "1.16.54-beta-20251027-105624-dfa978f8",
60
60
  "@blocklet/theme-builder": "^0.4.7",
61
61
  "@ocap/client": "^1.26.3",
62
62
  "@ocap/mcrypto": "^1.26.3",
@@ -155,9 +155,8 @@
155
155
  "engines": {
156
156
  "node": ">=14"
157
157
  },
158
- "gitHead": "73e5a3a80b82a2a7c62d42fdc08207b28e67633e",
158
+ "gitHead": "03b0bb26807c6c427ca700f48566ecc913f1353e",
159
159
  "devDependencies": {
160
- "@types/fs-extra": "^11.0.4",
161
- "@types/jest": "^29.5.13"
160
+ "@types/fs-extra": "^11.0.4"
162
161
  }
163
162
  }
@@ -1,135 +0,0 @@
1
- const logger = require('@abtnode/logger')('restart-running-component');
2
- const AsyncQueue = require('async/queue');
3
- const { BlockletStatus, BLOCKLET_MODES } = require('@blocklet/constant');
4
- const { getBlockletEngine } = require('@blocklet/meta/lib/engine');
5
- const { findComponentV2, forEachComponentV2, hasStartEngine, getDisplayName } = require('@blocklet/meta/lib/util');
6
- const { getComponentProcessId } = require('@blocklet/meta/lib/get-component-process-id');
7
- const getPm2ProcessInfo = require('@abtnode/util/lib/get-pm2-process-info');
8
- const formatContext = require('@abtnode/util/lib/format-context');
9
- const pAll = require('p-all');
10
-
11
- const createAuditLog = (wallet, node, action, args, result) => {
12
- return node
13
- .createAuditLog(
14
- {
15
- action,
16
- args,
17
- context: formatContext({
18
- user: { fullName: 'CLI', role: 'admin', did: wallet.address },
19
- headers: { 'user-agent': 'CLI' },
20
- }),
21
- result,
22
- },
23
- node
24
- )
25
- .catch(console.error);
26
- };
27
-
28
- const isHealthWithProcessId = async (processId) => {
29
- try {
30
- const info = await getPm2ProcessInfo(processId);
31
- if (info.pm2_env.status !== 'online') {
32
- // process not running
33
- return false;
34
- }
35
- } catch {
36
- // probably process not exists
37
- return false;
38
- }
39
- return true;
40
- };
41
-
42
- const getComponentDids = async ({ app }) => {
43
- const processNotRunnings = [];
44
- const needStoppedDids = [];
45
- await forEachComponentV2(app, async (component) => {
46
- if (component.mode === BLOCKLET_MODES.DEVELOPMENT) {
47
- needStoppedDids.push(component.meta.did);
48
- return;
49
- }
50
-
51
- if (component.status === BlockletStatus.waiting) {
52
- processNotRunnings.push(component.meta.did);
53
- return;
54
- }
55
-
56
- if (component.status !== BlockletStatus.running) {
57
- return;
58
- }
59
-
60
- if (!hasStartEngine(component.meta)) {
61
- return;
62
- }
63
-
64
- if (getBlockletEngine(component.meta)?.interpreter === 'blocklet') {
65
- return;
66
- }
67
-
68
- const processId = getComponentProcessId(component, [app]);
69
- const isHealth = await isHealthWithProcessId(processId);
70
- if (isHealth) {
71
- return;
72
- }
73
-
74
- processNotRunnings.push(component.meta.did);
75
- });
76
-
77
- return [processNotRunnings, needStoppedDids];
78
- };
79
-
80
- const restartRunningComponent = async (wallet, node) => {
81
- const queue = AsyncQueue(async (app, next) => {
82
- logger.info(`Restarting app ${getDisplayName(app)}...`);
83
- const [componentDids] = await getComponentDids({ app });
84
-
85
- if (!componentDids.length) {
86
- logger.info(`> No component need to restart for app ${getDisplayName(app)}`);
87
- next();
88
- return;
89
- }
90
-
91
- try {
92
- const result = await node.startBlocklet({ did: app.meta.did, checkHealthImmediately: true, componentDids }, {});
93
- logger.info(`> Restarted app ${getDisplayName(app)} / [${componentDids.join(',')}]`);
94
- await createAuditLog(wallet, node, 'startBlocklet', { did: app.meta.did, reason: 'on server restart' }, result);
95
- } catch (err) {
96
- logger.error(`> Restarted app ${getDisplayName(app)} / [${componentDids.join(',')}] failed`, err);
97
- }
98
-
99
- next();
100
- }, 1);
101
-
102
- const apps = await node.getBlocklets({ includeRuntimeInfo: false });
103
-
104
- const running = apps.filter((app) =>
105
- findComponentV2(app, (component) => component.status === BlockletStatus.running)
106
- );
107
-
108
- if (running.length === 0) {
109
- return;
110
- }
111
-
112
- await pAll(
113
- running.map((app) => async () => {
114
- try {
115
- const [componentDids, needStoppedDids] = await getComponentDids({ app });
116
- if (componentDids.length) {
117
- await node.setBlockletStatus(app.meta.did, BlockletStatus.waiting, {
118
- componentDids,
119
- });
120
- }
121
- if (needStoppedDids.length) {
122
- await node.stopBlocklet({ did: app.meta.did, componentDids: needStoppedDids });
123
- }
124
- } catch (err) {
125
- logger.error(`Failed to set blocklet ${getDisplayName(app)} status to waiting or stopped`, err);
126
- }
127
- }),
128
- { concurrency: 2 }
129
- );
130
-
131
- running.forEach((app) => queue.push(app));
132
- await queue.drain();
133
- };
134
-
135
- module.exports = restartRunningComponent;