@blocklet/cli 1.16.44 → 1.16.45-beta-20250609-082716-b6b0592b
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 +1 -1
- package/lib/commands/index.js +10 -0
- package/lib/commands/server/start.js +22 -2
- package/lib/commands/server/stop.js +4 -2
- package/lib/process/daemon.js +11 -0
- package/lib/process/service.js +7 -2
- package/lib/util/clear-all-cache.js +39 -0
- package/lib/util/index.js +1 -0
- package/package.json +24 -23
package/README.md
CHANGED
package/lib/commands/index.js
CHANGED
|
@@ -22,6 +22,7 @@ require('please-upgrade-node')(require('../../package.json'));
|
|
|
22
22
|
|
|
23
23
|
const { Command } = require('commander');
|
|
24
24
|
const last = require('lodash/last');
|
|
25
|
+
const path = require('path');
|
|
25
26
|
|
|
26
27
|
const { PROCESS_NAME_UPDATER, PROCESS_NAME_SERVICE, PROCESS_NAME_EVENT_HUB } = require('@abtnode/constant');
|
|
27
28
|
const debug = require('debug')('@blocklet/cli:blocklet');
|
|
@@ -54,6 +55,7 @@ const cleanup = require('./blocklet/cleanup');
|
|
|
54
55
|
const document = require('./blocklet/document');
|
|
55
56
|
const component = require('./blocklet/component');
|
|
56
57
|
const ServerCommand = require('./server/command');
|
|
58
|
+
const { getNode } = require('../node');
|
|
57
59
|
|
|
58
60
|
const program = new Command();
|
|
59
61
|
|
|
@@ -99,6 +101,10 @@ const parseOptions =
|
|
|
99
101
|
(handler) =>
|
|
100
102
|
async (...args) => {
|
|
101
103
|
const allOptions = getOptions(...args);
|
|
104
|
+
const { node } = await getNode({ dir: process.cwd() });
|
|
105
|
+
if (!process.env.ABT_NODE_CACHE_SQLITE_PATH) {
|
|
106
|
+
process.env.ABT_NODE_CACHE_SQLITE_PATH = path.join(node.dataDirs.core, 'db-cache.db');
|
|
107
|
+
}
|
|
102
108
|
await handler(allOptions);
|
|
103
109
|
};
|
|
104
110
|
|
|
@@ -112,6 +118,10 @@ const parseArgsAndOptions =
|
|
|
112
118
|
const options = last(args);
|
|
113
119
|
const allOptions = { ...commonOptions, ...options };
|
|
114
120
|
debug('parse options', allOptions);
|
|
121
|
+
const { node } = await getNode({ dir: process.cwd() });
|
|
122
|
+
if (!process.env.ABT_NODE_CACHE_SQLITE_PATH) {
|
|
123
|
+
process.env.ABT_NODE_CACHE_SQLITE_PATH = path.join(node.dataDirs.core, 'db-cache.db');
|
|
124
|
+
}
|
|
115
125
|
await handler(...args.slice(0, args.length - 1), allOptions);
|
|
116
126
|
};
|
|
117
127
|
|
|
@@ -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 =
|
|
61
|
+
const timeout = 20; // 20 seconds
|
|
60
62
|
try {
|
|
61
|
-
await tryWithTimeout(stop, timeout *
|
|
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.`);
|
package/lib/process/daemon.js
CHANGED
|
@@ -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');
|
package/lib/process/service.js
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/cli",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
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.
|
|
39
|
-
"@abtnode/client": "1.16.
|
|
40
|
-
"@abtnode/constant": "1.16.
|
|
41
|
-
"@abtnode/core": "1.16.
|
|
42
|
-
"@abtnode/
|
|
43
|
-
"@abtnode/
|
|
44
|
-
"@abtnode/
|
|
45
|
-
"@abtnode/
|
|
46
|
-
"@
|
|
47
|
-
"@arcblock/
|
|
38
|
+
"@abtnode/blocklet-services": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
39
|
+
"@abtnode/client": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
40
|
+
"@abtnode/constant": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
41
|
+
"@abtnode/core": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
42
|
+
"@abtnode/db-cache": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
43
|
+
"@abtnode/logger": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
44
|
+
"@abtnode/router-provider": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
45
|
+
"@abtnode/util": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
46
|
+
"@abtnode/webapp": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
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.
|
|
50
|
-
"@arcblock/ws": "1.20.
|
|
51
|
-
"@blocklet/constant": "1.16.
|
|
50
|
+
"@arcblock/jwt": "1.20.14",
|
|
51
|
+
"@arcblock/ws": "1.20.14",
|
|
52
|
+
"@blocklet/constant": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
52
53
|
"@blocklet/error": "^0.2.5",
|
|
53
54
|
"@blocklet/form-collector": "^0.1.8",
|
|
54
|
-
"@blocklet/images": "1.16.
|
|
55
|
-
"@blocklet/meta": "1.16.
|
|
56
|
-
"@blocklet/resolver": "1.16.
|
|
57
|
-
"@blocklet/store": "1.16.
|
|
55
|
+
"@blocklet/images": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
56
|
+
"@blocklet/meta": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
57
|
+
"@blocklet/resolver": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
58
|
+
"@blocklet/store": "1.16.45-beta-20250609-082716-b6b0592b",
|
|
58
59
|
"@blocklet/theme-builder": "^0.1.19",
|
|
59
|
-
"@ocap/client": "1.20.
|
|
60
|
-
"@ocap/mcrypto": "1.20.
|
|
61
|
-
"@ocap/util": "1.20.
|
|
62
|
-
"@ocap/wallet": "1.20.
|
|
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": "
|
|
157
|
+
"gitHead": "adeceb28a9b5c91d2eb35d33880782048ae629cc",
|
|
157
158
|
"devDependencies": {
|
|
158
159
|
"@types/fs-extra": "^11.0.4",
|
|
159
160
|
"@types/jest": "^29.5.13"
|