@abtnode/util 1.16.6-beta-1fde60e3 → 1.16.6-beta-7cbab489
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/did-document.js
CHANGED
|
@@ -116,13 +116,9 @@ const updateBlockletDocument = async ({
|
|
|
116
116
|
return updateWithRetry({ id: appPid, services, didRegistryUrl, alsoKnownAs, wallet });
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
-
const disableBlockletDNS = async ({ appPid, wallet, didRegistryUrl }) =>
|
|
120
|
-
updateWithRetry({ id: appPid, services: [], didRegistryUrl, wallet });
|
|
121
|
-
|
|
122
119
|
module.exports = {
|
|
123
120
|
updateServerDocument,
|
|
124
121
|
updateBlockletDocument,
|
|
125
|
-
disableBlockletDNS,
|
|
126
122
|
getDID,
|
|
127
123
|
getServerServices,
|
|
128
124
|
getBlockletServices,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const pm2 = require('./async-pm2');
|
|
2
|
+
const CustomError = require('./custom-error');
|
|
3
|
+
|
|
4
|
+
const noop = () => {};
|
|
5
|
+
|
|
6
|
+
const getPm2ProcessInfo = (processId, { printError = noop, throwOnNotExist = true } = {}) =>
|
|
7
|
+
new Promise((resolve, reject) => {
|
|
8
|
+
pm2.describe(processId, async (err, [info]) => {
|
|
9
|
+
if (err) {
|
|
10
|
+
printError('Failed to get blocklet status from pm2', { error: err });
|
|
11
|
+
return reject(err);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (!info && throwOnNotExist) {
|
|
15
|
+
return reject(new CustomError('BLOCKLET_PROCESS_404', 'Blocklet process info is not available'));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return resolve(info);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
module.exports = getPm2ProcessInfo;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const killProcess = require('fkill');
|
|
2
|
+
const getPm2ProcessInfo = require('./get-pm2-process-info');
|
|
3
|
+
|
|
4
|
+
const noop = () => {};
|
|
5
|
+
|
|
6
|
+
const killProcessOccupiedPorts = async ({ pm2ProcessId, ports = {}, printError = noop } = {}) => {
|
|
7
|
+
if (!pm2ProcessId) {
|
|
8
|
+
throw new Error('pm2ProcessId is required');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const info = await getPm2ProcessInfo(pm2ProcessId, { throwOnNotExist: false });
|
|
12
|
+
await Promise.all(
|
|
13
|
+
Object.entries(ports).map(async ([envName, configPort]) => {
|
|
14
|
+
if (!configPort) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const pm2ProcessPort = (info?.pm2_env?.env || {})[envName];
|
|
19
|
+
const pm2ProcessExist = pm2ProcessPort === configPort;
|
|
20
|
+
|
|
21
|
+
if (pm2ProcessExist) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
await killProcess(`:${configPort}`, { silent: true, force: true });
|
|
27
|
+
} catch (error) {
|
|
28
|
+
printError('Failed to kill process', { error });
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
module.exports = killProcessOccupiedPorts;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.6-beta-
|
|
6
|
+
"version": "1.16.6-beta-7cbab489",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.16.6-beta-
|
|
22
|
-
"@abtnode/logger": "1.16.6-beta-
|
|
23
|
-
"@blocklet/constant": "1.16.6-beta-
|
|
21
|
+
"@abtnode/constant": "1.16.6-beta-7cbab489",
|
|
22
|
+
"@abtnode/logger": "1.16.6-beta-7cbab489",
|
|
23
|
+
"@blocklet/constant": "1.16.6-beta-7cbab489",
|
|
24
24
|
"@ocap/client": "1.18.75",
|
|
25
25
|
"@ocap/mcrypto": "1.18.75",
|
|
26
26
|
"@ocap/util": "1.18.75",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"debug": "^4.3.4",
|
|
35
35
|
"fast-glob": "^3.2.12",
|
|
36
36
|
"find-up": "^5.0.0",
|
|
37
|
+
"fkill": "^7.2.1",
|
|
37
38
|
"flush-write-stream": "^2.0.0",
|
|
38
39
|
"folder-walker": "^3.2.0",
|
|
39
40
|
"get-folder-size": "^2.0.1",
|
|
@@ -70,5 +71,5 @@
|
|
|
70
71
|
"jest": "^27.5.1",
|
|
71
72
|
"unzipper": "^0.10.11"
|
|
72
73
|
},
|
|
73
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "36b58c0651762472ac34ad880965c47510eb9768"
|
|
74
75
|
}
|