@constellation-network/node-pilot 0.13.0-omegatest.8 → 0.13.0
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 +10 -28
- package/dist/checks/check-dependencies.js +13 -20
- package/dist/checks/check-initial-setup.d.ts +0 -10
- package/dist/checks/check-initial-setup.js +7 -55
- package/dist/checks/check-node-ctl.d.ts +5 -0
- package/dist/checks/check-node-ctl.js +88 -0
- package/dist/checks/check-pilot.d.ts +0 -1
- package/dist/checks/check-pilot.js +8 -34
- package/dist/checks/check-project.js +3 -4
- package/dist/commands/config.js +1 -1
- package/dist/commands/info.js +2 -2
- package/dist/commands/status.js +5 -2
- package/dist/config-store.d.ts +0 -4
- package/dist/config-store.js +0 -5
- package/dist/helpers/project-helper.d.ts +3 -3
- package/dist/helpers/project-helper.js +12 -15
- package/dist/services/fastforward-service.js +9 -8
- package/dist/services/migration-service.d.ts +1 -1
- package/dist/services/migration-service.js +25 -23
- package/dist/services/node-service.d.ts +3 -0
- package/dist/services/node-service.js +12 -14
- package/dist/services/shell-service.js +5 -8
- package/dist/services/systemd-service.d.ts +0 -1
- package/dist/services/systemd-service.js +6 -19
- package/install-dependencies.sh +1 -1
- package/oclif.manifest.json +1 -24
- package/package.json +2 -3
- package/projects/hypergraph/Dockerfile +2 -2
- package/projects/hypergraph/docker-compose.yml +4 -4
- package/projects/hypergraph/networks/mainnet/network.env +3 -3
- package/projects/hypergraph/networks/testnet/network.env +3 -3
- package/projects/hypergraph/scripts/install-dependencies.sh +19 -19
- package/scripts/install_services.sh +5 -10
- package/dist/commands/uninstall.d.ts +0 -6
- package/dist/commands/uninstall.js +0 -24
- package/install-java-21.sh +0 -110
- package/scripts/uninstall_services.sh +0 -37
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ $ npm install -g @constellation-network/node-pilot
|
|
|
21
21
|
$ cpilot COMMAND
|
|
22
22
|
running command...
|
|
23
23
|
$ cpilot (--version|-v)
|
|
24
|
-
@constellation-network/node-pilot/0.13.0
|
|
24
|
+
@constellation-network/node-pilot/0.13.0 darwin-arm64 node-v22.15.0
|
|
25
25
|
$ cpilot --help [COMMAND]
|
|
26
26
|
USAGE
|
|
27
27
|
$ cpilot COMMAND
|
|
@@ -47,7 +47,6 @@ If no command is entered, node-pilot will automatically perform a series of chec
|
|
|
47
47
|
* [`cpilot restart [LAYER]`](#cpilot-restart-layer)
|
|
48
48
|
* [`cpilot shutdown`](#cpilot-shutdown)
|
|
49
49
|
* [`cpilot status`](#cpilot-status)
|
|
50
|
-
* [`cpilot uninstall`](#cpilot-uninstall)
|
|
51
50
|
|
|
52
51
|
## `cpilot clean [LAYER]`
|
|
53
52
|
|
|
@@ -72,7 +71,7 @@ EXAMPLES
|
|
|
72
71
|
$ cpilot clean
|
|
73
72
|
```
|
|
74
73
|
|
|
75
|
-
_See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0
|
|
74
|
+
_See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0/src/commands/clean.ts)_
|
|
76
75
|
|
|
77
76
|
## `cpilot config`
|
|
78
77
|
|
|
@@ -89,7 +88,7 @@ EXAMPLES
|
|
|
89
88
|
$ cpilot config
|
|
90
89
|
```
|
|
91
90
|
|
|
92
|
-
_See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0
|
|
91
|
+
_See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0/src/commands/config.ts)_
|
|
93
92
|
|
|
94
93
|
## `cpilot config get [NAME]`
|
|
95
94
|
|
|
@@ -113,7 +112,7 @@ EXAMPLES
|
|
|
113
112
|
$ cpilot config get gl0:CL_PUBLIC_HTTP_PORT
|
|
114
113
|
```
|
|
115
114
|
|
|
116
|
-
_See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0
|
|
115
|
+
_See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0/src/commands/config/get.ts)_
|
|
117
116
|
|
|
118
117
|
## `cpilot config set NAME VALUE`
|
|
119
118
|
|
|
@@ -136,7 +135,7 @@ EXAMPLES
|
|
|
136
135
|
$ cpilot config set gl0:CL_PUBLIC_HTTP_PORT 9000
|
|
137
136
|
```
|
|
138
137
|
|
|
139
|
-
_See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0
|
|
138
|
+
_See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0/src/commands/config/set.ts)_
|
|
140
139
|
|
|
141
140
|
## `cpilot help [COMMAND]`
|
|
142
141
|
|
|
@@ -173,7 +172,7 @@ EXAMPLES
|
|
|
173
172
|
$ cpilot info
|
|
174
173
|
```
|
|
175
174
|
|
|
176
|
-
_See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0
|
|
175
|
+
_See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0/src/commands/info.ts)_
|
|
177
176
|
|
|
178
177
|
## `cpilot logs LAYER`
|
|
179
178
|
|
|
@@ -199,7 +198,7 @@ EXAMPLES
|
|
|
199
198
|
$ cpilot logs
|
|
200
199
|
```
|
|
201
200
|
|
|
202
|
-
_See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0
|
|
201
|
+
_See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0/src/commands/logs.ts)_
|
|
203
202
|
|
|
204
203
|
## `cpilot restart [LAYER]`
|
|
205
204
|
|
|
@@ -227,7 +226,7 @@ EXAMPLES
|
|
|
227
226
|
$ cpilot restart
|
|
228
227
|
```
|
|
229
228
|
|
|
230
|
-
_See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0
|
|
229
|
+
_See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0/src/commands/restart.ts)_
|
|
231
230
|
|
|
232
231
|
## `cpilot shutdown`
|
|
233
232
|
|
|
@@ -244,7 +243,7 @@ EXAMPLES
|
|
|
244
243
|
$ cpilot shutdown
|
|
245
244
|
```
|
|
246
245
|
|
|
247
|
-
_See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0
|
|
246
|
+
_See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0/src/commands/shutdown.ts)_
|
|
248
247
|
|
|
249
248
|
## `cpilot status`
|
|
250
249
|
|
|
@@ -258,22 +257,5 @@ DESCRIPTION
|
|
|
258
257
|
Display node status and configuration settings
|
|
259
258
|
```
|
|
260
259
|
|
|
261
|
-
_See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0
|
|
262
|
-
|
|
263
|
-
## `cpilot uninstall`
|
|
264
|
-
|
|
265
|
-
Uninstall Node Pilot
|
|
266
|
-
|
|
267
|
-
```
|
|
268
|
-
USAGE
|
|
269
|
-
$ cpilot uninstall
|
|
270
|
-
|
|
271
|
-
DESCRIPTION
|
|
272
|
-
Uninstall Node Pilot
|
|
273
|
-
|
|
274
|
-
EXAMPLES
|
|
275
|
-
$ cpilot uninstall
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
_See code: [src/commands/uninstall.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0-omegatest.8/src/commands/uninstall.ts)_
|
|
260
|
+
_See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0/src/commands/status.ts)_
|
|
279
261
|
<!-- commandsstop -->
|
|
@@ -22,28 +22,21 @@ export const checkDependencies = async () => {
|
|
|
22
22
|
}
|
|
23
23
|
const isDockerInstalled = await shellService.checkCommandAvailable('docker');
|
|
24
24
|
const pilotDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../..`);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
clm.
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
await shellService.runCommand(`sudo usermod -aG docker ${user}`);
|
|
35
|
-
clm.postStep(`\n✅ Added user "${user}" to the docker group`);
|
|
36
|
-
clm.warn('\nPlease logout and login again in order for the group changes take effect.\n');
|
|
25
|
+
if (fs.existsSync(path.join(pilotDir, 'install-dependencies.sh'))) {
|
|
26
|
+
if (!isDockerInstalled) {
|
|
27
|
+
clm.step('Docker is required and needs to be installed.');
|
|
28
|
+
await promptHelper.doYouWishToContinue();
|
|
29
|
+
await installDependencies(pilotDir);
|
|
30
|
+
clm.postStep(`\nDocker has been installed. Please logout and login again to ensure the changes take effect. Then run cpilot again.`);
|
|
31
|
+
clm.echo('');
|
|
37
32
|
process.exit(0);
|
|
38
33
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
clm.echo('');
|
|
46
|
-
process.exit(0);
|
|
34
|
+
const isACLInstalled = await shellService.checkCommandAvailable('setfacl');
|
|
35
|
+
if (!isACLInstalled && os.platform() === 'linux') {
|
|
36
|
+
clm.step('ACL is required and needs to be installed.');
|
|
37
|
+
await promptHelper.doYouWishToContinue();
|
|
38
|
+
await installDependencies(pilotDir);
|
|
39
|
+
}
|
|
47
40
|
}
|
|
48
41
|
};
|
|
49
42
|
async function installDependencies(pilotDir) {
|
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
export declare const checkInitialSetup: {
|
|
2
|
-
checkExistingUsers(): Promise<void>;
|
|
3
2
|
firstTimeRun(): Promise<void>;
|
|
4
|
-
getExistingInstallations(): Promise<{
|
|
5
|
-
currentUser: string;
|
|
6
|
-
otherUsers: never[];
|
|
7
|
-
rootUserHasPilot?: undefined;
|
|
8
|
-
} | {
|
|
9
|
-
currentUser: string;
|
|
10
|
-
otherUsers: string[];
|
|
11
|
-
rootUserHasPilot: boolean;
|
|
12
|
-
}>;
|
|
13
3
|
};
|
|
@@ -1,67 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { clm } from "../clm.js";
|
|
1
|
+
import chalk from "chalk";
|
|
5
2
|
import { configStore } from "../config-store.js";
|
|
6
|
-
import { shellService } from "../services/shell-service.js";
|
|
7
3
|
import { systemdService } from "../services/systemd-service.js";
|
|
8
4
|
import { checkDependencies } from "./check-dependencies.js";
|
|
9
5
|
import { checkHardware } from "./check-hardware.js";
|
|
10
6
|
export const checkInitialSetup = {
|
|
11
|
-
async checkExistingUsers() {
|
|
12
|
-
const { otherUsers } = await this.getExistingInstallations();
|
|
13
|
-
if (otherUsers.length > 0) {
|
|
14
|
-
clm.warn(`There are other users that have Node Pilot installed.\n ${otherUsers.join('\n ')}`);
|
|
15
|
-
clm.warn('To uninstall for another user, login as the user and run "cpilot uninstall".');
|
|
16
|
-
clm.error('Node Pilot can only be installed for one user at a time.\n');
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
7
|
async firstTimeRun() {
|
|
20
|
-
if (configStore.
|
|
8
|
+
if (configStore.getSystemInfo() !== null) {
|
|
21
9
|
return;
|
|
22
10
|
}
|
|
23
11
|
await checkDependencies();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// console.log(" " + chalk.whiteBright("CONSTELLATION NETWORK") + " ");
|
|
30
|
-
// console.log(" " + chalk.whiteBright("NODE PILOT") + " ");
|
|
31
|
-
// console.log(chalk.whiteBright(" ****************************************"));
|
|
12
|
+
console.log(chalk.whiteBright("\n ****************************************"));
|
|
13
|
+
console.log(" " + chalk.whiteBright("CONSTELLATION NETWORK") + " ");
|
|
14
|
+
console.log(" " + chalk.whiteBright("NODE PILOT") + " ");
|
|
15
|
+
console.log(chalk.whiteBright(" ****************************************"));
|
|
16
|
+
await checkHardware.systemRequirements();
|
|
32
17
|
await systemdService.install();
|
|
33
|
-
configStore.setProjectFlag('firstTimeChecked', true);
|
|
34
18
|
},
|
|
35
|
-
async getExistingInstallations() {
|
|
36
|
-
const platform = os.platform();
|
|
37
|
-
const isLinux = platform === 'linux';
|
|
38
|
-
const homeFolder = isLinux ? '/home' : '/Users';
|
|
39
|
-
const currentUser = os.userInfo().username;
|
|
40
|
-
if (!fs.existsSync(homeFolder)) {
|
|
41
|
-
clm.warn(`Home folder path does not exist: ${homeFolder}`);
|
|
42
|
-
return { currentUser, otherUsers: [] };
|
|
43
|
-
}
|
|
44
|
-
const userFolders = fs.readdirSync(homeFolder).filter(file => fs.lstatSync(path.join(homeFolder, file)).isDirectory());
|
|
45
|
-
const usersWithPilot = [];
|
|
46
|
-
for (const folder of userFolders) {
|
|
47
|
-
const dirPath = path.join(homeFolder, folder, '.node-pilot');
|
|
48
|
-
// eslint-disable-next-line no-await-in-loop
|
|
49
|
-
const exists = await shellService.runCommandWithOutput(`sudo test -d "${dirPath}" && echo 1 || echo 0`);
|
|
50
|
-
if (exists === '1')
|
|
51
|
-
usersWithPilot.push(folder);
|
|
52
|
-
}
|
|
53
|
-
let rootUserHasPilot = false;
|
|
54
|
-
if (isLinux) {
|
|
55
|
-
const dirPath = path.join('/root', '.node-pilot');
|
|
56
|
-
const exists = await shellService.runCommandWithOutput(`sudo test -d "${dirPath}" && echo 1 || echo 0`);
|
|
57
|
-
if (exists === '1') {
|
|
58
|
-
usersWithPilot.push('root');
|
|
59
|
-
rootUserHasPilot = true;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// console.log(`Current currentUser: ${currentUser}`);
|
|
63
|
-
// console.log(`Users with Node Pilot installed: ${usersWithPilot.join(', ')}`);
|
|
64
|
-
// console.log(`Root currentUser has Node Pilot installed: ${rootUserHasPilot}`);
|
|
65
|
-
return { currentUser, otherUsers: usersWithPilot.filter(u => u !== currentUser), rootUserHasPilot };
|
|
66
|
-
}
|
|
67
19
|
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { input, password } from "@inquirer/prompts";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import yaml from "yaml";
|
|
6
|
+
import { clm } from "../clm.js";
|
|
7
|
+
import { configStore } from "../config-store.js";
|
|
8
|
+
import { keyFileHelper } from "../helpers/key-file-helper.js";
|
|
9
|
+
import { promptHelper } from "../helpers/prompt-helper.js";
|
|
10
|
+
import { dockerService } from "../services/docker-service.js";
|
|
11
|
+
import { nodeService } from "../services/node-service.js";
|
|
12
|
+
import { shellService } from "../services/shell-service.js";
|
|
13
|
+
export const checkNodeCtl = {
|
|
14
|
+
async check4Migration() {
|
|
15
|
+
if (configStore.hasProjectFlag('nodeCtlChecked')) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const { name } = configStore.getProjectInfo();
|
|
19
|
+
if (name.toLowerCase() !== 'hypergraph') {
|
|
20
|
+
configStore.setProjectFlag('nodeCtlChecked', true);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const hasNodeAdminUser = fs.existsSync('/home/nodeadmin');
|
|
24
|
+
if (hasNodeAdminUser) {
|
|
25
|
+
const isDockerRunning = await dockerService.isRunning();
|
|
26
|
+
const isPortOpen = await nodeService.isPortInUse(9000);
|
|
27
|
+
clm.step(chalk.bold('NODECTL has been detected.'));
|
|
28
|
+
if (!isDockerRunning && isPortOpen) {
|
|
29
|
+
clm.error('Please shutdown any Nodes being managed by NODECTL before proceeding.');
|
|
30
|
+
}
|
|
31
|
+
const cnPath = path.resolve('/var/tessellation/nodectl/cn-config.yaml');
|
|
32
|
+
if (fs.existsSync(cnPath)) {
|
|
33
|
+
const answer = await input({
|
|
34
|
+
default: 'y',
|
|
35
|
+
message: 'Would you like to import key file from nodectl? (y/n): '
|
|
36
|
+
});
|
|
37
|
+
if (answer.toLowerCase() === 'y') {
|
|
38
|
+
await this.importKeyInfo(cnPath);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
configStore.setProjectFlag('nodeCtlChecked', true);
|
|
43
|
+
},
|
|
44
|
+
async importKeyInfo(cnPath) {
|
|
45
|
+
clm.step('Importing key file from nodectl...');
|
|
46
|
+
try {
|
|
47
|
+
clm.preStep('Making a sudo call to read the nodectl config file...');
|
|
48
|
+
await shellService.runCommand(`sudo chmod +r ${cnPath}`);
|
|
49
|
+
const doc = yaml.parse(fs.readFileSync(cnPath, 'utf8'));
|
|
50
|
+
// console.log(JSON.stringify(doc,null,2));
|
|
51
|
+
// eslint-disable-next-line camelcase
|
|
52
|
+
const { key_location, key_name } = doc.nodectl.global_p12;
|
|
53
|
+
const nodeCtlKeyPath = path.resolve(key_location, key_name);
|
|
54
|
+
clm.debug(`Found key file path in nodectl config file: ${nodeCtlKeyPath}`);
|
|
55
|
+
clm.step('Key file found at ' + chalk.cyan(nodeCtlKeyPath));
|
|
56
|
+
clm.preStep('Importing key file...');
|
|
57
|
+
const { projectDir } = configStore.getProjectInfo();
|
|
58
|
+
const pilotKeyPath = path.join(projectDir, 'key.p12');
|
|
59
|
+
// copy file to home directory, change owner to current user, and make it readable by all
|
|
60
|
+
clm.preStep('Making a sudo call to copy the key file...');
|
|
61
|
+
await shellService.runCommand(`sudo cp ${nodeCtlKeyPath} ${pilotKeyPath}; sudo chown $(whoami) ${pilotKeyPath}; chmod +r ${pilotKeyPath}`);
|
|
62
|
+
await this.promptForKeyFile(pilotKeyPath);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error(error);
|
|
66
|
+
clm.warn('Failed to import key information from nodectl. You will need to import it manually.');
|
|
67
|
+
await promptHelper.doYouWishToContinue();
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
async promptForKeyFile(pilotKeyPath) {
|
|
71
|
+
// prompt for password
|
|
72
|
+
const keyPassword = await password({ message: 'Enter the key file password:' });
|
|
73
|
+
const keyAlias = await input({ message: 'Enter the key file alias:' });
|
|
74
|
+
configStore.setEnvInfo({ CL_KEYALIAS: keyAlias, CL_KEYSTORE: pilotKeyPath, CL_PASSWORD: keyPassword });
|
|
75
|
+
try {
|
|
76
|
+
const dagAddress = await keyFileHelper.getAddress();
|
|
77
|
+
const nodeId = await keyFileHelper.getId();
|
|
78
|
+
configStore.setProjectInfo({ dagAddress, nodeId });
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
clm.warn('Failed to unlock the key file. Please check your key file information and try again.');
|
|
82
|
+
fs.rmSync(pilotKeyPath);
|
|
83
|
+
await this.promptForKeyFile(pilotKeyPath);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
clm.postStep('Key file imported successfully.\n');
|
|
87
|
+
}
|
|
88
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import os from "node:os";
|
|
2
2
|
import semver from "semver";
|
|
3
|
+
import packageJson from '../../package.json' with { type: 'json' };
|
|
3
4
|
import { clm } from "../clm.js";
|
|
4
5
|
import { configStore } from "../config-store.js";
|
|
5
6
|
import { healthCheckConfig } from "../helpers/health-check-config.js";
|
|
@@ -8,7 +9,6 @@ import { promptHelper } from "../helpers/prompt-helper.js";
|
|
|
8
9
|
import { dockerService } from "../services/docker-service.js";
|
|
9
10
|
import { nodeService } from "../services/node-service.js";
|
|
10
11
|
import { shellService } from "../services/shell-service.js";
|
|
11
|
-
import { checkInitialSetup } from "./check-initial-setup.js";
|
|
12
12
|
const REGISTRY_URL = 'https://registry.npmjs.org/';
|
|
13
13
|
export const checkNodePilot = {
|
|
14
14
|
async checkDiscordRegistration() {
|
|
@@ -18,17 +18,6 @@ export const checkNodePilot = {
|
|
|
18
18
|
await this.promptDiscordRegistration();
|
|
19
19
|
configStore.setProjectFlag('discordChecked', true);
|
|
20
20
|
},
|
|
21
|
-
async checkMultipleUsers() {
|
|
22
|
-
if (configStore.hasProjectFlag('multipleUsersChecked')) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const { currentUser, otherUsers } = await checkInitialSetup.getExistingInstallations();
|
|
26
|
-
if (otherUsers.length > 0) {
|
|
27
|
-
clm.warn(`Multiple users have Node Pilot installed.\n ${currentUser} <-- current user\n ${otherUsers.join('\n ')}`);
|
|
28
|
-
clm.error('Login and run "cpilot uninstall" to remove the extra installation(s).');
|
|
29
|
-
}
|
|
30
|
-
configStore.setProjectFlag('multipleUsersChecked', true);
|
|
31
|
-
},
|
|
32
21
|
async checkVersion() {
|
|
33
22
|
const { currentVer, latestVer } = await this.compareVersions();
|
|
34
23
|
if (!latestVer || !currentVer || latestVer.compare(currentVer) === 0)
|
|
@@ -71,14 +60,13 @@ export const checkNodePilot = {
|
|
|
71
60
|
await shellService.runCommand(`sudo npm install -g @constellation-network/node-pilot@${latestVer.version}`);
|
|
72
61
|
if (hasMajorMinorChange) {
|
|
73
62
|
clm.step('Updating scripts and configuration files...');
|
|
74
|
-
projectHelper.upgradeHypergraph();
|
|
63
|
+
await projectHelper.upgradeHypergraph();
|
|
75
64
|
}
|
|
76
65
|
clm.postStep('Update completed. Run cpilot again to use the latest version');
|
|
77
66
|
process.exit(0);
|
|
78
67
|
},
|
|
79
68
|
async compareVersions() {
|
|
80
|
-
const
|
|
81
|
-
const packageUrl = new URL(encodeURIComponent(pilotReleaseName).replace(/^%40/, '@'), REGISTRY_URL);
|
|
69
|
+
const packageUrl = new URL(encodeURIComponent(packageJson.name).replace(/^%40/, '@'), REGISTRY_URL);
|
|
82
70
|
const headers = {
|
|
83
71
|
accept: 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*',
|
|
84
72
|
};
|
|
@@ -86,24 +74,10 @@ export const checkNodePilot = {
|
|
|
86
74
|
if (!result) {
|
|
87
75
|
return { currentVer: undefined, latestVer: undefined };
|
|
88
76
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
else if (pilotVersion.includes('omegatest')) {
|
|
94
|
-
distTag = 'omegatest';
|
|
95
|
-
}
|
|
96
|
-
else if (pilotVersion.includes('intnet')) {
|
|
97
|
-
distTag = 'intnet';
|
|
98
|
-
}
|
|
99
|
-
const latestVer = semver.parse(result['dist-tags'][distTag]);
|
|
100
|
-
const currentVer = semver.parse(pilotVersion);
|
|
101
|
-
if (latestVer !== null && currentVer !== null) {
|
|
102
|
-
clm.debug(`Current version: ${currentVer?.version}, Latest version: ${latestVer?.version}`);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
clm.warn(`Unable to resolve version from dist-tag ${distTag} - ${JSON.stringify(result['dist-tags'])}`);
|
|
106
|
-
}
|
|
77
|
+
const { type } = configStore.getNetworkInfo();
|
|
78
|
+
const networkTag = type === 'testnet' ? 'testnet' : 'latest';
|
|
79
|
+
const latestVer = semver.parse(result['dist-tags'][networkTag]);
|
|
80
|
+
const currentVer = semver.parse(packageJson.version);
|
|
107
81
|
return { currentVer, latestVer };
|
|
108
82
|
},
|
|
109
83
|
isDiscordAlertsEnabled() {
|
|
@@ -143,7 +117,7 @@ export const checkNodePilot = {
|
|
|
143
117
|
const hasMajorMinorChange = latestVer.major !== currentVer.major || latestVer.minor !== currentVer.minor;
|
|
144
118
|
if (hasMajorMinorChange) {
|
|
145
119
|
clm.step('Updating scripts and configuration files...');
|
|
146
|
-
projectHelper.upgradeHypergraph();
|
|
120
|
+
await projectHelper.upgradeHypergraph();
|
|
147
121
|
}
|
|
148
122
|
}
|
|
149
123
|
};
|
|
@@ -12,9 +12,8 @@ import { shellService } from "../services/shell-service.js";
|
|
|
12
12
|
import { checkNetwork } from "./check-network.js";
|
|
13
13
|
function getJavaMemoryOptions(network, mem) {
|
|
14
14
|
if (network === 'testnet') {
|
|
15
|
-
const linuxOpt = (os.platform() === 'linux') ? ' -XX:+UseZGC
|
|
16
|
-
|
|
17
|
-
return `-Xms${mem}g -Xmx${mem}g${linuxOpt} -XX:+UseStringDeduplication --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED`;
|
|
15
|
+
const linuxOpt = (os.platform() === 'linux') ? ' -XX:+UseZGC' : '';
|
|
16
|
+
return `-Xms${mem}g -Xmx${mem}g -XX:+UnlockExperimentalVMOptions${linuxOpt} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./heap_dumps/ -XX:+ExitOnOutOfMemoryError`;
|
|
18
17
|
}
|
|
19
18
|
return `-Xms1024M -Xmx${mem}g -Xss256K`;
|
|
20
19
|
}
|
|
@@ -63,7 +62,7 @@ export const checkProject = {
|
|
|
63
62
|
const network = type.toUpperCase();
|
|
64
63
|
const logMethod = type === currentNetwork ? clm.postStep : clm.debug;
|
|
65
64
|
logMethod(`${network}:: ${layersToRun[0]} memory allocation: ${mainLayerMem}GB`);
|
|
66
|
-
configStore.setEnvLayerInfo(type, layersToRun[0], { CL_DOCKER_JAVA_OPTS: getJavaMemoryOptions(
|
|
65
|
+
configStore.setEnvLayerInfo(type, layersToRun[0], { CL_DOCKER_JAVA_OPTS: getJavaMemoryOptions(currentNetwork, mainLayerMem) });
|
|
67
66
|
if (subLayerMem) {
|
|
68
67
|
logMethod(`${network}:: ${layersToRun[1]} memory allocation: ${subLayerMem}GB`);
|
|
69
68
|
configStore.setEnvLayerInfo(type, layersToRun[1], { CL_DOCKER_JAVA_OPTS: `-Xms1024M -Xmx${subLayerMem}G -Xss256K` });
|
package/dist/commands/config.js
CHANGED
|
@@ -25,7 +25,7 @@ export default class Config extends Command {
|
|
|
25
25
|
{ name: 'Java Memory', value: 'javaMemory' },
|
|
26
26
|
{ name: 'Key File', value: 'keyFile' },
|
|
27
27
|
{ name: 'Layers To Run', value: 'layersToRun' },
|
|
28
|
-
{ name: `
|
|
28
|
+
{ name: `Network`, value: 'network' },
|
|
29
29
|
],
|
|
30
30
|
message: 'What would you like to change?:',
|
|
31
31
|
});
|
package/dist/commands/info.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import packageJson from '../../package.json' with { type: 'json' };
|
|
2
3
|
import { checkNodePilot } from "../checks/check-pilot.js";
|
|
3
4
|
import { configStore } from "../config-store.js";
|
|
4
5
|
import { configHelper } from "../helpers/config-helper.js";
|
|
@@ -13,11 +14,10 @@ export default class Info extends Command {
|
|
|
13
14
|
const networkInfo = configStore.getNetworkInfo();
|
|
14
15
|
const { CL_EXTERNAL_IP: currentIpAddress } = configStore.getEnvInfo();
|
|
15
16
|
const { CL_DOCKER_JAVA_OPTS } = configStore.getEnvLayerInfo(networkInfo.type, 'gl0');
|
|
16
|
-
const { version } = configStore.getPilotReleaseInfo();
|
|
17
17
|
// Project Name
|
|
18
18
|
configHelper.showEnvInfo('Project Name', projectInfo.name);
|
|
19
19
|
// Pilot Version
|
|
20
|
-
configHelper.showEnvInfo('Node Pilot Version', version);
|
|
20
|
+
configHelper.showEnvInfo('Node Pilot Version', packageJson.version);
|
|
21
21
|
// External IP Address
|
|
22
22
|
configHelper.showEnvInfo('External IP Address', currentIpAddress);
|
|
23
23
|
// DAG Address
|
package/dist/commands/status.js
CHANGED
|
@@ -2,28 +2,31 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
import { checkInitialSetup } from "../checks/check-initial-setup.js";
|
|
3
3
|
import { checkLayers } from "../checks/check-layers.js";
|
|
4
4
|
import { checkNetwork } from "../checks/check-network.js";
|
|
5
|
+
import { checkNodeCtl } from "../checks/check-node-ctl.js";
|
|
5
6
|
import { checkNodePilot } from "../checks/check-pilot.js";
|
|
6
7
|
import { checkProject } from "../checks/check-project.js";
|
|
7
8
|
import { checkWallet } from "../checks/check-wallet.js";
|
|
8
9
|
import { keyFileHelper } from "../helpers/key-file-helper.js";
|
|
9
10
|
import { migrationService } from "../services/migration-service.js";
|
|
10
11
|
export default class Status extends Command {
|
|
12
|
+
// eslint-disable-next-line no-warning-comments
|
|
13
|
+
// TODO add -f flag to continuously monitor status
|
|
11
14
|
static description = 'Display node status and configuration settings';
|
|
12
15
|
async run() {
|
|
13
16
|
await checkInstallationAndConfigurationStatus();
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
19
|
export async function checkInstallationAndConfigurationStatus() {
|
|
20
|
+
await migrationService.runMigrations();
|
|
17
21
|
await checkInitialSetup.firstTimeRun();
|
|
18
|
-
await checkNodePilot.checkMultipleUsers();
|
|
19
22
|
await checkProject.projectInstallation();
|
|
20
|
-
migrationService.runMigrations();
|
|
21
23
|
await checkProject.checkJavaMemory();
|
|
22
24
|
await checkNetwork.checkExternalIpAddress();
|
|
23
25
|
await checkNetwork.isNetworkConnectable();
|
|
24
26
|
await checkNodePilot.checkDiscordRegistration();
|
|
25
27
|
await checkNodePilot.checkVersion();
|
|
26
28
|
await checkProject.releaseVersion();
|
|
29
|
+
await checkNodeCtl.check4Migration();
|
|
27
30
|
await keyFileHelper.promptIfNoKeyFile();
|
|
28
31
|
await checkNetwork.checkSeedList();
|
|
29
32
|
await checkNetwork.checkForExistingNodeIdInCluster();
|
package/dist/config-store.d.ts
CHANGED
|
@@ -12,10 +12,6 @@ declare class ConfigStore {
|
|
|
12
12
|
getEnvNetworkInfo(network: NetworkType): EnvNetworkInfo;
|
|
13
13
|
getLayerPortInfo(layer: TessellationLayer): PortInfo;
|
|
14
14
|
getNetworkInfo(): NetworkInfo;
|
|
15
|
-
getPilotReleaseInfo(): {
|
|
16
|
-
name: string;
|
|
17
|
-
version: string;
|
|
18
|
-
};
|
|
19
15
|
getProjectInfo(): ProjectInfo;
|
|
20
16
|
getProjects(): string[];
|
|
21
17
|
getRunningProjects(): string[];
|
package/dist/config-store.js
CHANGED
|
@@ -3,9 +3,7 @@ import { JSONStorage } from "node-localstorage";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import packageJson from '../package.json' with { type: 'json' };
|
|
7
6
|
import { clm } from "./clm.js";
|
|
8
|
-
const pilotReleaseInfo = { name: packageJson.name, version: packageJson.version };
|
|
9
7
|
class EmptyStorage extends JSONStorage {
|
|
10
8
|
constructor() { super("/tmp"); }
|
|
11
9
|
getItem(_key) { return null; }
|
|
@@ -84,9 +82,6 @@ class ConfigStore {
|
|
|
84
82
|
getNetworkInfo() {
|
|
85
83
|
return this.projectStore.getItem('network');
|
|
86
84
|
}
|
|
87
|
-
getPilotReleaseInfo() {
|
|
88
|
-
return pilotReleaseInfo;
|
|
89
|
-
}
|
|
90
85
|
getProjectInfo() {
|
|
91
86
|
return this.projectStore.getItem('project') || {};
|
|
92
87
|
}
|
|
@@ -9,7 +9,7 @@ export declare const projectHelper: {
|
|
|
9
9
|
installProject(name: string, projectFolder: string): Promise<void>;
|
|
10
10
|
prepareDataFolder(): void;
|
|
11
11
|
selectProject(): Promise<void>;
|
|
12
|
-
upgradeEmbedded(name: string): void
|
|
13
|
-
upgradeHypergraph(): void
|
|
14
|
-
upgradeProject(name: string, projectFolder: string): void
|
|
12
|
+
upgradeEmbedded(name: string): Promise<void>;
|
|
13
|
+
upgradeHypergraph(): Promise<void>;
|
|
14
|
+
upgradeProject(name: string, projectFolder: string): Promise<void>;
|
|
15
15
|
};
|
|
@@ -79,8 +79,6 @@ export const projectHelper = {
|
|
|
79
79
|
clm.error(`Project folder not found: ${projectFolder}`);
|
|
80
80
|
}
|
|
81
81
|
await this.installProject(name, projectFolder);
|
|
82
|
-
// Set the project version to match the latest Pilot version. This prevents previous migration scripts from running.
|
|
83
|
-
configStore.setProjectInfo({ version: configStore.getPilotReleaseInfo().version });
|
|
84
82
|
},
|
|
85
83
|
// curl -s https://api.github.com/repos/Constellation-Labs/pacaswap-metagraph/releases/latest | jq -r '.assets[] | select(.name | contains("node-pilot"))'
|
|
86
84
|
// use .tag_name for the release version
|
|
@@ -89,15 +87,14 @@ export const projectHelper = {
|
|
|
89
87
|
},
|
|
90
88
|
async installHypergraph() {
|
|
91
89
|
await this.installEmbedded('hypergraph');
|
|
90
|
+
const { projectDir } = configStore.getProjectInfo();
|
|
91
|
+
const { platform } = configStore.getSystemInfo();
|
|
92
92
|
this.prepareDataFolder();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// // set permission for group "docker" on the layer folder and any subfolders created later
|
|
99
|
-
// await shellService.runCommand(`sudo setfacl -Rm g:docker:rwX -dm g:docker:rwX ${layerDir}`)
|
|
100
|
-
// }
|
|
93
|
+
if (platform === 'linux') {
|
|
94
|
+
const layerDir = path.join(projectDir, 'gl0');
|
|
95
|
+
// set permission for group "docker" on the layer folder and any subfolders created later
|
|
96
|
+
await shellService.runCommand(`sudo setfacl -Rm g:docker:rwX -dm g:docker:rwX ${layerDir}`);
|
|
97
|
+
}
|
|
101
98
|
this.importEnvFiles();
|
|
102
99
|
},
|
|
103
100
|
async installProject(name, projectFolder) {
|
|
@@ -173,18 +170,18 @@ export const projectHelper = {
|
|
|
173
170
|
}
|
|
174
171
|
}
|
|
175
172
|
},
|
|
176
|
-
upgradeEmbedded(name) {
|
|
173
|
+
async upgradeEmbedded(name) {
|
|
177
174
|
const projectFolder = path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../projects/${name}`);
|
|
178
175
|
if (!fs.existsSync(projectFolder)) {
|
|
179
176
|
clm.error(`Project folder not found: ${projectFolder}`);
|
|
180
177
|
}
|
|
181
|
-
this.upgradeProject(name, projectFolder);
|
|
178
|
+
await this.upgradeProject(name, projectFolder);
|
|
182
179
|
},
|
|
183
|
-
upgradeHypergraph() {
|
|
184
|
-
this.upgradeEmbedded('hypergraph');
|
|
180
|
+
async upgradeHypergraph() {
|
|
181
|
+
await this.upgradeEmbedded('hypergraph');
|
|
185
182
|
this.importEnvFiles();
|
|
186
183
|
},
|
|
187
|
-
upgradeProject(name, projectFolder) {
|
|
184
|
+
async upgradeProject(name, projectFolder) {
|
|
188
185
|
const { projectDir } = configStore.getProjectInfo();
|
|
189
186
|
clm.debug(`Upgrading project from ${projectFolder} to ${projectDir}`);
|
|
190
187
|
fs.cpSync(projectFolder, projectDir, { recursive: true });
|