@blocklet/cli 1.16.44 → 1.16.45-beta-20250609-025419-7fd1f86c

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/README.md CHANGED
@@ -28,7 +28,7 @@ Powered By
28
28
  / ___ \| | | (__| |_) | | (_) | (__| <
29
29
  /_/ \_\_| \___|____/|_|\___/ \___|_|\_\
30
30
 
31
- Blocklet CLI v1.16.43
31
+ Blocklet CLI v1.16.44
32
32
 
33
33
  Usage: blocklet server [options] [command]
34
34
 
@@ -19,7 +19,7 @@ const { runMigrationScripts, runSchemaMigrations } = require('@abtnode/core/lib/
19
19
  const { clearRouterByConfigKeyword } = require('@abtnode/router-provider');
20
20
  const yaml = require('js-yaml');
21
21
  const semver = require('semver');
22
- const { BlockletEvents } = require('@blocklet/constant');
22
+ const { BlockletEvents, ABT_NODE_KERNEL_OR_BLOCKLET_MODE } = require('@blocklet/constant');
23
23
  const {
24
24
  PROCESS_NAME_PROXY,
25
25
  PROCESS_NAME_DAEMON,
@@ -39,6 +39,7 @@ const {
39
39
  } = require('@abtnode/constant');
40
40
 
41
41
  const { canUseFileSystemIsolateApi, SAFE_NODE_VERSION } = require('@abtnode/util/lib/security');
42
+ const { ensureDockerRedis } = require('@abtnode/core/lib/util/docker/ensure-docker-redis');
42
43
 
43
44
  const { version } = require('../../../package.json');
44
45
  const debug = require('../../debug')('start');
@@ -247,6 +248,7 @@ const startService = async (logDir, maxMemoryRestart, environments) => {
247
248
  wait_ready: true,
248
249
  max_restarts: 3,
249
250
  listen_timeout: 3000,
251
+ pmx: false,
250
252
  time: true,
251
253
  env: {
252
254
  ...environments,
@@ -255,6 +257,7 @@ const startService = async (logDir, maxMemoryRestart, environments) => {
255
257
  execMode: 'cluster',
256
258
  mergeLogs: true,
257
259
  instances: getServiceInstanceNumber(),
260
+ interpreter_args: environments.ABT_NODE_KERNEL_MODE === ABT_NODE_KERNEL_OR_BLOCKLET_MODE.PERFORMANT ? [] : ['--optimize_for_size'],
258
261
  });
259
262
 
260
263
  await ensureEndpointHealthy({
@@ -394,6 +397,16 @@ const prepareInitialData = async (node, config, dataDir) => {
394
397
  };
395
398
 
396
399
  const exec = async ({ workingDir, config, dataDir, mode, updateDb, forceIntranet }) => {
400
+ if (!process.env.ABT_NODE_CACHE_SQLITE_PATH) {
401
+ process.env.ABT_NODE_CACHE_SQLITE_PATH = path.join(dataDir, 'core', 'db-cache.db');
402
+ }
403
+
404
+ const redisUrl = await ensureDockerRedis();
405
+ if (redisUrl) {
406
+ process.env.ABT_NODE_CACHE_REDIS_URL = redisUrl;
407
+ printSuccess(`Using Redis Cache: ${process.env.ABT_NODE_CACHE_REDIS_URL}`);
408
+ }
409
+
397
410
  const configFile = await getConfigFile(workingDir);
398
411
 
399
412
  const proxyMaxMemoryLimit = get(config, 'node.runtimeConfig.proxyMaxMemoryLimit', PROXY_MAX_MEM_LIMIT_IN_MB);
@@ -556,6 +569,9 @@ const exec = async ({ workingDir, config, dataDir, mode, updateDb, forceIntranet
556
569
  ABT_NODE_PORT: config.node.port,
557
570
  ABT_NODE_SESSION_SECRET: config.node.secret,
558
571
  ABT_NODE_DATA_DIR: dataDir,
572
+ ABT_NODE_CACHE_REDIS_URL: process.env.ABT_NODE_CACHE_REDIS_URL,
573
+ ABT_NODE_KERNEL_MODE: process.env.ABT_NODE_KERNEL_MODE,
574
+ ABT_NODE_BLOCKLET_MODE: process.env.ABT_NODE_BLOCKLET_MODE,
559
575
  ABT_NODE_CONFIG_FILE: configFile,
560
576
  ABT_NODE_BLOCKLET_PORT: config.blocklet.port,
561
577
  ABT_NODE_UPDATER_PORT: getPort(PROCESS_NAME_UPDATER),
@@ -610,8 +626,12 @@ const exec = async ({ workingDir, config, dataDir, mode, updateDb, forceIntranet
610
626
  listen_timeout: 3000,
611
627
  env: environments,
612
628
  time: true,
629
+ pmx: false,
630
+ interpreter_args:
631
+ environments.ABT_NODE_KERNEL_MODE === ABT_NODE_KERNEL_OR_BLOCKLET_MODE.PERFORMANT
632
+ ? []
633
+ : ['--optimize_for_size'],
613
634
  });
614
-
615
635
  // check daemon
616
636
  await ensureEndpointHealthy({
617
637
  protocol: 'tcp',
@@ -31,10 +31,12 @@ const {
31
31
  const { getNode } = require('../../node');
32
32
  const { checkRunning } = require('../../manager');
33
33
  const { wrapSpinner } = require('../../ui');
34
+ const clearAllCache = require('../../util/clear-all-cache');
34
35
 
35
36
  const forceStopServer = async () => {
36
37
  const stop = async () => {
37
38
  try {
39
+ await clearAllCache(printSuccess, printError);
38
40
  const results = await Promise.all([
39
41
  clearRouterByConfigKeyword(CONFIG_FOLDER_NAME),
40
42
  clearRouterByConfigKeyword(CONFIG_FOLDER_NAME_OLD),
@@ -56,9 +58,9 @@ const forceStopServer = async () => {
56
58
  printError(`Blocklet Server related processes stop failed: ${error.message}`);
57
59
  }
58
60
  };
59
- const timeout = 10; // 10 seconds
61
+ const timeout = 20; // 20 seconds
60
62
  try {
61
- await tryWithTimeout(stop, timeout * 1000);
63
+ await tryWithTimeout(stop, timeout * 2000);
62
64
  } catch (err) {
63
65
  printError(`Blocklet server failed to stop within ${timeout} seconds`);
64
66
  printInfo(`You can stop blocklet server with ${chalk.cyan(`${getCLICommandName()} stop --force`)} again.`);
@@ -1,11 +1,17 @@
1
1
  /* eslint-disable no-console */
2
2
  /* eslint-disable no-await-in-loop */
3
+
3
4
  if (!process.env.NODE_ENV) {
4
5
  process.env.NODE_ENV = 'production';
5
6
  }
6
7
 
7
8
  const fs = require('fs');
8
9
  const path = require('path');
10
+
11
+ if (!process.env.ABT_NODE_CACHE_SQLITE_PATH) {
12
+ process.env.ABT_NODE_CACHE_SQLITE_PATH = path.join(process.env.ABT_NODE_DATA_DIR, 'core', 'db-cache.db');
13
+ }
14
+
9
15
  const { joinURL } = require('ufo');
10
16
 
11
17
  process.env.ABT_NODE_LOG_NAME = 'daemon';
@@ -14,10 +20,15 @@ process.env.ABT_NODE_LOG_DIR = path.join(process.env.ABT_NODE_DATA_DIR, 'logs',
14
20
  const runningBefore = !!process.env.BLOCKLET_SERVER_RUNNING_BEFORE;
15
21
 
16
22
  const logger = require('@abtnode/logger')('daemon');
23
+
17
24
  const ABTNode = require('@abtnode/core');
25
+
18
26
  const getNodeWallet = require('@abtnode/util/lib/get-app-wallet');
27
+
19
28
  const { getDisplayName } = require('@blocklet/meta/lib/util');
29
+
20
30
  const { SERVER_STATUS } = require('@abtnode/constant');
31
+
21
32
  const createServer = require('@abtnode/webapp/blocklet'); // eslint-disable-line
22
33
 
23
34
  const restartRunningComponent = require('../util/restart-running-component');
@@ -1,9 +1,14 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
1
4
  if (!process.env.NODE_ENV) {
2
5
  process.env.NODE_ENV = 'production';
3
6
  }
4
7
 
5
- const fs = require('fs');
6
- const path = require('path');
8
+ if (!process.env.ABT_NODE_CACHE_SQLITE_PATH) {
9
+ process.env.ABT_NODE_CACHE_SQLITE_PATH = path.join(process.env.ABT_NODE_DATA_DIR, 'core', 'db-cache.db');
10
+ }
11
+
7
12
  const { joinURL } = require('ufo');
8
13
  const { BlockletStatus, BlockletInternalEvents } = require('@blocklet/constant');
9
14
  const { filterComponentsV2 } = require('@blocklet/meta/lib/util');
@@ -0,0 +1,39 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const { DBCache, getAbtNodeRedisAndSQLiteUrl } = require('@abtnode/db-cache');
5
+ const { stopDockerRedis } = require('@abtnode/core/lib/util/docker/ensure-docker-redis');
6
+ const { CONFIG_FOLDER_NAME, CONFIG_FOLDER_NAME_OLD } = require('@abtnode/constant');
7
+
8
+ const clearAllCache = async (printSuccess, printError) => {
9
+ // 停止 docker 中的 redis 容器
10
+ await stopDockerRedis();
11
+ try {
12
+ let nowConfigFolder = '';
13
+ if (fs.existsSync(CONFIG_FOLDER_NAME)) {
14
+ nowConfigFolder = CONFIG_FOLDER_NAME;
15
+ } else if (fs.existsSync(CONFIG_FOLDER_NAME_OLD)) {
16
+ nowConfigFolder = CONFIG_FOLDER_NAME_OLD;
17
+ }
18
+ if (nowConfigFolder) {
19
+ if (!process.env.ABT_NODE_CACHE_SQLITE_PATH) {
20
+ process.env.ABT_NODE_CACHE_SQLITE_PATH = path.join(nowConfigFolder, 'core', 'db-cache.db');
21
+ }
22
+
23
+ const cache = new DBCache(() => ({
24
+ ...getAbtNodeRedisAndSQLiteUrl(),
25
+ prefix: 'all',
26
+ ttl: 1000 * 60,
27
+ forceType: 'sqlite',
28
+ }));
29
+
30
+ // 清理 sqlite adapter 的缓存
31
+ await cache.flushAll();
32
+ }
33
+ } catch (error) {
34
+ printError(`Clear all db cache failed: ${error.message}`);
35
+ }
36
+ printSuccess('Clear all db cache success');
37
+ };
38
+
39
+ module.exports = clearAllCache;
package/lib/util/index.js CHANGED
@@ -239,6 +239,7 @@ const startEventHub = async (logDir, maxMemoryRestart = PROXY_MAX_MEM_LIMIT_IN_M
239
239
  max_restarts: 3,
240
240
  listen_timeout: 3000,
241
241
  time: true,
242
+ pmx: false,
242
243
  env: {
243
244
  ABT_NODE_EVENT_PORT: port,
244
245
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/cli",
3
- "version": "1.16.44",
3
+ "version": "1.16.45-beta-20250609-025419-7fd1f86c",
4
4
  "description": "Command line tools to manage Blocklet Server",
5
5
  "homepage": "https://github.com/ArcBlock/blocklet-server#readme",
6
6
  "bin": {
@@ -35,31 +35,32 @@
35
35
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
36
36
  },
37
37
  "dependencies": {
38
- "@abtnode/blocklet-services": "1.16.44",
39
- "@abtnode/client": "1.16.44",
40
- "@abtnode/constant": "1.16.44",
41
- "@abtnode/core": "1.16.44",
42
- "@abtnode/logger": "1.16.44",
43
- "@abtnode/router-provider": "1.16.44",
44
- "@abtnode/util": "1.16.44",
45
- "@abtnode/webapp": "1.16.44",
46
- "@arcblock/did": "1.20.13",
47
- "@arcblock/event-hub": "1.20.13",
38
+ "@abtnode/blocklet-services": "1.16.45-beta-20250609-025419-7fd1f86c",
39
+ "@abtnode/client": "1.16.45-beta-20250609-025419-7fd1f86c",
40
+ "@abtnode/constant": "1.16.45-beta-20250609-025419-7fd1f86c",
41
+ "@abtnode/core": "1.16.45-beta-20250609-025419-7fd1f86c",
42
+ "@abtnode/db-cache": "1.16.45-beta-20250609-025419-7fd1f86c",
43
+ "@abtnode/logger": "1.16.45-beta-20250609-025419-7fd1f86c",
44
+ "@abtnode/router-provider": "1.16.45-beta-20250609-025419-7fd1f86c",
45
+ "@abtnode/util": "1.16.45-beta-20250609-025419-7fd1f86c",
46
+ "@abtnode/webapp": "1.16.45-beta-20250609-025419-7fd1f86c",
47
+ "@arcblock/did": "1.20.14",
48
+ "@arcblock/event-hub": "1.20.14",
48
49
  "@arcblock/ipfs-only-hash": "^0.0.2",
49
- "@arcblock/jwt": "1.20.13",
50
- "@arcblock/ws": "1.20.13",
51
- "@blocklet/constant": "1.16.44",
50
+ "@arcblock/jwt": "1.20.14",
51
+ "@arcblock/ws": "1.20.14",
52
+ "@blocklet/constant": "1.16.45-beta-20250609-025419-7fd1f86c",
52
53
  "@blocklet/error": "^0.2.5",
53
54
  "@blocklet/form-collector": "^0.1.8",
54
- "@blocklet/images": "1.16.44",
55
- "@blocklet/meta": "1.16.44",
56
- "@blocklet/resolver": "1.16.44",
57
- "@blocklet/store": "1.16.44",
55
+ "@blocklet/images": "1.16.45-beta-20250609-025419-7fd1f86c",
56
+ "@blocklet/meta": "1.16.45-beta-20250609-025419-7fd1f86c",
57
+ "@blocklet/resolver": "1.16.45-beta-20250609-025419-7fd1f86c",
58
+ "@blocklet/store": "1.16.45-beta-20250609-025419-7fd1f86c",
58
59
  "@blocklet/theme-builder": "^0.1.19",
59
- "@ocap/client": "1.20.13",
60
- "@ocap/mcrypto": "1.20.13",
61
- "@ocap/util": "1.20.13",
62
- "@ocap/wallet": "1.20.13",
60
+ "@ocap/client": "1.20.14",
61
+ "@ocap/mcrypto": "1.20.14",
62
+ "@ocap/util": "1.20.14",
63
+ "@ocap/wallet": "1.20.14",
63
64
  "@vercel/ncc": "^0.38.3",
64
65
  "archiver": "^7.0.1",
65
66
  "async": "^3.2.4",
@@ -153,7 +154,7 @@
153
154
  "engines": {
154
155
  "node": ">=14"
155
156
  },
156
- "gitHead": "a177f040e3e8da94311cec1395c8e8defae2da9e",
157
+ "gitHead": "0457b82da528653a1b903149ea1fb1966c31bee3",
157
158
  "devDependencies": {
158
159
  "@types/fs-extra": "^11.0.4",
159
160
  "@types/jest": "^29.5.13"