@abtnode/core 1.16.10-beta-cceee857 → 1.16.10-beta-90abf54e
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.
|
@@ -1803,19 +1803,19 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
1803
1803
|
oldBlocklet,
|
|
1804
1804
|
});
|
|
1805
1805
|
|
|
1806
|
-
if (context.startImmediately) {
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
} catch (error) {
|
|
1813
|
-
logger.warn('attempt to start immediately failed', { did, error });
|
|
1814
|
-
}
|
|
1806
|
+
if (context.startImmediately && installedBlocklet?.settings.initialized) {
|
|
1807
|
+
try {
|
|
1808
|
+
logger.info('start blocklet after installed', { did });
|
|
1809
|
+
await this.start({ did, checkHealthImmediately: true });
|
|
1810
|
+
} catch (error) {
|
|
1811
|
+
logger.warn('attempt to start immediately failed', { did, error });
|
|
1815
1812
|
}
|
|
1816
1813
|
}
|
|
1814
|
+
|
|
1815
|
+
return installedBlocklet;
|
|
1817
1816
|
} catch (err) {
|
|
1818
1817
|
logger.error('blocklet onInstall error', { err });
|
|
1818
|
+
return null;
|
|
1819
1819
|
}
|
|
1820
1820
|
}
|
|
1821
1821
|
|
|
@@ -44,6 +44,8 @@ const installApplicationFromBackup = async ({
|
|
|
44
44
|
throw new Error(`dir(${dir}) does not exist`);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
context.startImmediately = true;
|
|
48
|
+
|
|
47
49
|
// parse data from source dir
|
|
48
50
|
const srcBundleDirs = await getAppDirs(path.join(dir, 'blocklets'));
|
|
49
51
|
|
|
@@ -128,6 +130,8 @@ const installApplicationFromBackup = async ({
|
|
|
128
130
|
|
|
129
131
|
logger.info('installFromBackup', { srcBundleDirs, srcDataDir });
|
|
130
132
|
|
|
133
|
+
let blocklet = null;
|
|
134
|
+
|
|
131
135
|
try {
|
|
132
136
|
// copy extra
|
|
133
137
|
const existExtra = await states.blockletExtras.find({ did });
|
|
@@ -144,7 +148,7 @@ const installApplicationFromBackup = async ({
|
|
|
144
148
|
logger.info('blocklet extra is copied successfully');
|
|
145
149
|
|
|
146
150
|
// add blocklet
|
|
147
|
-
await states.blocklet.addBlocklet(blockletState);
|
|
151
|
+
blocklet = await states.blocklet.addBlocklet(blockletState);
|
|
148
152
|
logger.info('blocklet state is added successfully');
|
|
149
153
|
|
|
150
154
|
// copy bundle
|
|
@@ -214,7 +218,7 @@ const installApplicationFromBackup = async ({
|
|
|
214
218
|
const state = await states.blocklet.setBlockletStatus(did, BlockletStatus.installing);
|
|
215
219
|
manager.emit(BlockletEvents.statusChange, state);
|
|
216
220
|
|
|
217
|
-
return manager.
|
|
221
|
+
return manager._onInstall({ blocklet, did, context });
|
|
218
222
|
}
|
|
219
223
|
|
|
220
224
|
try {
|
package/lib/event.js
CHANGED
|
@@ -52,7 +52,7 @@ module.exports = ({
|
|
|
52
52
|
eventHub.on(name, (data) => {
|
|
53
53
|
if (name === BlockletEvents.removed) {
|
|
54
54
|
// Cleanup cache in teamManager for every node instance
|
|
55
|
-
teamManager.deleteTeam(data?.meta?.did
|
|
55
|
+
teamManager.deleteTeam(data?.meta?.did);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// clear cache
|
package/lib/team/manager.js
CHANGED
|
@@ -13,8 +13,14 @@ const logger = require('@abtnode/logger')('@abtnode/core:team:manager');
|
|
|
13
13
|
const { ROLES, RBAC_CONFIG } = require('@abtnode/constant');
|
|
14
14
|
const { BlockletEvents } = require('@blocklet/constant');
|
|
15
15
|
const Lock = require('@abtnode/util/lib/lock');
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const {
|
|
17
|
+
BaseState,
|
|
18
|
+
doSchemaMigration,
|
|
19
|
+
createSequelize,
|
|
20
|
+
destroySequelize,
|
|
21
|
+
getBlockletModels,
|
|
22
|
+
setupModels,
|
|
23
|
+
} = require('@abtnode/models');
|
|
18
24
|
|
|
19
25
|
const { isCLI, getDbFilePath } = require('../util');
|
|
20
26
|
|
|
@@ -35,23 +41,6 @@ const getDefaultTeamState = () => ({
|
|
|
35
41
|
session: null,
|
|
36
42
|
});
|
|
37
43
|
|
|
38
|
-
const closeDatabase = async (db) =>
|
|
39
|
-
new Promise((resolve, reject) => {
|
|
40
|
-
if (!db || process.env.NODE_ENV === 'test') {
|
|
41
|
-
resolve(true);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
db.closeDatabase((err) => {
|
|
46
|
-
if (err) {
|
|
47
|
-
reject(err);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
resolve(true);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
44
|
class TeamManager extends EventEmitter {
|
|
56
45
|
constructor({ nodeDid, dataDirs, states }) {
|
|
57
46
|
super();
|
|
@@ -69,6 +58,7 @@ class TeamManager extends EventEmitter {
|
|
|
69
58
|
this.cache = {};
|
|
70
59
|
|
|
71
60
|
this.models = new Map();
|
|
61
|
+
this.connections = new Map();
|
|
72
62
|
|
|
73
63
|
this.init();
|
|
74
64
|
}
|
|
@@ -340,38 +330,20 @@ class TeamManager extends EventEmitter {
|
|
|
340
330
|
};
|
|
341
331
|
}
|
|
342
332
|
|
|
343
|
-
|
|
344
|
-
async deleteTeam(did, { closeDatabase: closeDB = false } = {}) {
|
|
333
|
+
async deleteTeam(did, { closeDatabase = true } = {}) {
|
|
345
334
|
if (!did) {
|
|
346
335
|
logger.error('deleteTeam: did does not exist');
|
|
347
336
|
return;
|
|
348
337
|
}
|
|
349
338
|
|
|
350
|
-
logger.info('deleteTeam', { did,
|
|
339
|
+
logger.info('deleteTeam', { did, closeDatabase });
|
|
351
340
|
|
|
352
341
|
const pid = await this.getPid(did);
|
|
353
|
-
|
|
342
|
+
const connection = this.connections.get(did) || this.connections.get(pid);
|
|
343
|
+
if (closeDatabase && connection) {
|
|
354
344
|
logger.info('deleteTeam.closeDatabase', { did });
|
|
355
345
|
try {
|
|
356
|
-
|
|
357
|
-
await closeDatabase(this.cache[pid].rbac.storage.db);
|
|
358
|
-
}
|
|
359
|
-
if (this.cache[pid].user) {
|
|
360
|
-
await closeDatabase(this.cache[pid].user.db);
|
|
361
|
-
}
|
|
362
|
-
if (this.cache[pid].passport) {
|
|
363
|
-
await closeDatabase(this.cache[pid].passport.db);
|
|
364
|
-
}
|
|
365
|
-
if (this.cache[pid].connectedAccount) {
|
|
366
|
-
await closeDatabase(this.cache[pid].connectedAccount.db);
|
|
367
|
-
}
|
|
368
|
-
if (this.cache[pid].session) {
|
|
369
|
-
await closeDatabase(this.cache[pid].session.db);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// NOTICE: wait for nedb to finish closeDatabase
|
|
373
|
-
const timeout = process.env.NODE_ENV !== 'test' ? 2000 : 200;
|
|
374
|
-
await sleep(timeout);
|
|
346
|
+
await destroySequelize(connection);
|
|
375
347
|
} catch (error) {
|
|
376
348
|
logger.error('Failed to close database', { did, error });
|
|
377
349
|
}
|
|
@@ -379,6 +351,10 @@ class TeamManager extends EventEmitter {
|
|
|
379
351
|
|
|
380
352
|
this.cache[did] = null;
|
|
381
353
|
this.cache[pid] = null;
|
|
354
|
+
this.models.delete(did);
|
|
355
|
+
this.models.delete(pid);
|
|
356
|
+
this.connections.delete(did);
|
|
357
|
+
this.connections.delete(pid);
|
|
382
358
|
}
|
|
383
359
|
|
|
384
360
|
// =======
|
|
@@ -411,6 +387,7 @@ class TeamManager extends EventEmitter {
|
|
|
411
387
|
setupModels(models, sequelize);
|
|
412
388
|
await this.initDatabase(did);
|
|
413
389
|
this.models.set(did, models);
|
|
390
|
+
this.connections.set(did, file);
|
|
414
391
|
}
|
|
415
392
|
|
|
416
393
|
return this.models.get(did);
|
package/lib/util/blocklet.js
CHANGED
|
@@ -1552,7 +1552,7 @@ const consumeServerlessNFT = async ({ nftId, nodeInfo, blocklet }) => {
|
|
|
1552
1552
|
},
|
|
1553
1553
|
});
|
|
1554
1554
|
|
|
1555
|
-
logger.
|
|
1555
|
+
logger.info('consume serverless nft success', { nftId, hash: result.hash });
|
|
1556
1556
|
} catch (error) {
|
|
1557
1557
|
logger.error('consume serverless nft failed', { nftId, error });
|
|
1558
1558
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.10-beta-
|
|
6
|
+
"version": "1.16.10-beta-90abf54e",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/auth": "1.16.10-beta-
|
|
23
|
-
"@abtnode/certificate-manager": "1.16.10-beta-
|
|
24
|
-
"@abtnode/constant": "1.16.10-beta-
|
|
25
|
-
"@abtnode/cron": "1.16.10-beta-
|
|
26
|
-
"@abtnode/logger": "1.16.10-beta-
|
|
27
|
-
"@abtnode/models": "1.16.10-beta-
|
|
28
|
-
"@abtnode/queue": "1.16.10-beta-
|
|
29
|
-
"@abtnode/rbac": "1.16.10-beta-
|
|
30
|
-
"@abtnode/router-provider": "1.16.10-beta-
|
|
31
|
-
"@abtnode/static-server": "1.16.10-beta-
|
|
32
|
-
"@abtnode/timemachine": "1.16.10-beta-
|
|
33
|
-
"@abtnode/util": "1.16.10-beta-
|
|
22
|
+
"@abtnode/auth": "1.16.10-beta-90abf54e",
|
|
23
|
+
"@abtnode/certificate-manager": "1.16.10-beta-90abf54e",
|
|
24
|
+
"@abtnode/constant": "1.16.10-beta-90abf54e",
|
|
25
|
+
"@abtnode/cron": "1.16.10-beta-90abf54e",
|
|
26
|
+
"@abtnode/logger": "1.16.10-beta-90abf54e",
|
|
27
|
+
"@abtnode/models": "1.16.10-beta-90abf54e",
|
|
28
|
+
"@abtnode/queue": "1.16.10-beta-90abf54e",
|
|
29
|
+
"@abtnode/rbac": "1.16.10-beta-90abf54e",
|
|
30
|
+
"@abtnode/router-provider": "1.16.10-beta-90abf54e",
|
|
31
|
+
"@abtnode/static-server": "1.16.10-beta-90abf54e",
|
|
32
|
+
"@abtnode/timemachine": "1.16.10-beta-90abf54e",
|
|
33
|
+
"@abtnode/util": "1.16.10-beta-90abf54e",
|
|
34
34
|
"@arcblock/did": "1.18.80",
|
|
35
35
|
"@arcblock/did-auth": "1.18.80",
|
|
36
36
|
"@arcblock/did-ext": "^1.18.80",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"@arcblock/pm2-events": "^0.0.5",
|
|
42
42
|
"@arcblock/validator": "^1.18.80",
|
|
43
43
|
"@arcblock/vc": "1.18.80",
|
|
44
|
-
"@blocklet/constant": "1.16.10-beta-
|
|
45
|
-
"@blocklet/meta": "1.16.10-beta-
|
|
46
|
-
"@blocklet/sdk": "1.16.10-beta-
|
|
44
|
+
"@blocklet/constant": "1.16.10-beta-90abf54e",
|
|
45
|
+
"@blocklet/meta": "1.16.10-beta-90abf54e",
|
|
46
|
+
"@blocklet/sdk": "1.16.10-beta-90abf54e",
|
|
47
47
|
"@did-space/client": "^0.2.99",
|
|
48
48
|
"@fidm/x509": "^1.2.1",
|
|
49
49
|
"@ocap/mcrypto": "1.18.80",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"express": "^4.18.2",
|
|
97
97
|
"jest": "^27.5.1"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "724462068e8b20d662f0461b03799da7b11b7b60"
|
|
100
100
|
}
|