@constellation-network/node-pilot 0.0.11 → 0.0.12
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 +9 -9
- package/dist/checks/check-hardware.js +1 -1
- package/dist/commands/logs.js +1 -1
- package/dist/commands/restart.js +15 -15
- package/dist/config-store.d.ts +1 -0
- package/dist/helpers/project-helper.js +2 -2
- package/dist/services/archiver-service.js +3 -3
- package/dist/services/fastforward-service.js +15 -3
- package/dist/services/systemd-service.js +10 -11
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
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.0.
|
24
|
+
@constellation-network/node-pilot/0.0.12 darwin-arm64 node-v22.15.0
|
25
25
|
$ cpilot --help [COMMAND]
|
26
26
|
USAGE
|
27
27
|
$ cpilot COMMAND
|
@@ -62,7 +62,7 @@ EXAMPLES
|
|
62
62
|
$ cpilot config
|
63
63
|
```
|
64
64
|
|
65
|
-
_See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.
|
65
|
+
_See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.12/src/commands/config.ts)_
|
66
66
|
|
67
67
|
## `cpilot config get [NAME]`
|
68
68
|
|
@@ -86,7 +86,7 @@ EXAMPLES
|
|
86
86
|
$ cpilot config get gl0:CL_PUBLIC_HTTP_PORT
|
87
87
|
```
|
88
88
|
|
89
|
-
_See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.
|
89
|
+
_See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.12/src/commands/config/get.ts)_
|
90
90
|
|
91
91
|
## `cpilot config set NAME VALUE`
|
92
92
|
|
@@ -109,7 +109,7 @@ EXAMPLES
|
|
109
109
|
$ cpilot config set gl0:CL_PUBLIC_HTTP_PORT 9000
|
110
110
|
```
|
111
111
|
|
112
|
-
_See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.
|
112
|
+
_See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.12/src/commands/config/set.ts)_
|
113
113
|
|
114
114
|
## `cpilot help [COMMAND]`
|
115
115
|
|
@@ -146,7 +146,7 @@ EXAMPLES
|
|
146
146
|
$ cpilot info
|
147
147
|
```
|
148
148
|
|
149
|
-
_See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.
|
149
|
+
_See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.12/src/commands/info.ts)_
|
150
150
|
|
151
151
|
## `cpilot logs LAYER`
|
152
152
|
|
@@ -170,7 +170,7 @@ EXAMPLES
|
|
170
170
|
$ cpilot logs
|
171
171
|
```
|
172
172
|
|
173
|
-
_See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.
|
173
|
+
_See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.12/src/commands/logs.ts)_
|
174
174
|
|
175
175
|
## `cpilot restart [LAYER]`
|
176
176
|
|
@@ -198,7 +198,7 @@ EXAMPLES
|
|
198
198
|
$ cpilot restart
|
199
199
|
```
|
200
200
|
|
201
|
-
_See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.
|
201
|
+
_See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.12/src/commands/restart.ts)_
|
202
202
|
|
203
203
|
## `cpilot shutdown`
|
204
204
|
|
@@ -215,7 +215,7 @@ EXAMPLES
|
|
215
215
|
$ cpilot shutdown
|
216
216
|
```
|
217
217
|
|
218
|
-
_See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.
|
218
|
+
_See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.12/src/commands/shutdown.ts)_
|
219
219
|
|
220
220
|
## `cpilot status`
|
221
221
|
|
@@ -229,5 +229,5 @@ DESCRIPTION
|
|
229
229
|
Display node status and configuration settings
|
230
230
|
```
|
231
231
|
|
232
|
-
_See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.
|
232
|
+
_See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.12/src/commands/status.ts)_
|
233
233
|
<!-- commandsstop -->
|
@@ -45,6 +45,6 @@ export const checkHardware = {
|
|
45
45
|
clm.warn("System recommendations not met. The validator node may not function properly.\n");
|
46
46
|
await promptHelper.doYouWishToContinue('n');
|
47
47
|
}
|
48
|
-
configStore.setSystemInfo({ cores: numOfCores, disk: totalSpaceGB, memory: totalMemoryGB, platform: os.platform() });
|
48
|
+
configStore.setSystemInfo({ cores: numOfCores, disk: totalSpaceGB, memory: totalMemoryGB, platform: os.platform(), user: os.userInfo().username });
|
49
49
|
}
|
50
50
|
};
|
package/dist/commands/logs.js
CHANGED
@@ -28,7 +28,7 @@ export default class Logs extends Command {
|
|
28
28
|
tailFlag = ' -f';
|
29
29
|
}
|
30
30
|
const { projectDir } = configStore.getProjectInfo();
|
31
|
-
const logPath = path.join(projectDir,
|
31
|
+
const logPath = path.join(projectDir, args.layer, 'logs', 'app.log');
|
32
32
|
await shellService.runCommand(`tail ${tailFlag} ${logPath}`).catch(() => 1);
|
33
33
|
}
|
34
34
|
}
|
package/dist/commands/restart.js
CHANGED
@@ -22,21 +22,6 @@ export default class Restart extends BaseCommand {
|
|
22
22
|
const { args, flags } = await this.parse(Restart);
|
23
23
|
this.checkProject(flags);
|
24
24
|
configHelper.assertProject('No project found. ');
|
25
|
-
if (!await dockerService.isRunning()) {
|
26
|
-
this.error('The validator node is not running.');
|
27
|
-
}
|
28
|
-
if (args && args.layer) {
|
29
|
-
const { layersToRun } = configStore.getProjectInfo();
|
30
|
-
const layer = args.layer;
|
31
|
-
if (!layersToRun.includes(layer)) {
|
32
|
-
this.error(`Invalid layer: ${layer}. Available layers: ${layersToRun.join(',')}`);
|
33
|
-
}
|
34
|
-
await nodeService.leaveCluster(layer);
|
35
|
-
await nodeService.pollForLayersState([layer], 'Offline');
|
36
|
-
clm.preStep(`Restarting ${layer.toUpperCase()}...`);
|
37
|
-
await dockerService.dockerRestart(layer);
|
38
|
-
return;
|
39
|
-
}
|
40
25
|
if (flags.update) {
|
41
26
|
const project = configStore.getActiveProject();
|
42
27
|
for (const project of configStore.getRunningProjects()) {
|
@@ -60,6 +45,21 @@ export default class Restart extends BaseCommand {
|
|
60
45
|
configStore.setActiveProject(project);
|
61
46
|
return;
|
62
47
|
}
|
48
|
+
if (!await dockerService.isRunning()) {
|
49
|
+
this.error('The validator node is not running.');
|
50
|
+
}
|
51
|
+
if (args && args.layer) {
|
52
|
+
const { layersToRun } = configStore.getProjectInfo();
|
53
|
+
const layer = args.layer;
|
54
|
+
if (!layersToRun.includes(layer)) {
|
55
|
+
this.error(`Invalid layer: ${layer}. Available layers: ${layersToRun.join(',')}`);
|
56
|
+
}
|
57
|
+
await nodeService.leaveCluster(layer);
|
58
|
+
await nodeService.pollForLayersState([layer], 'Offline');
|
59
|
+
clm.preStep(`Restarting ${layer.toUpperCase()}...`);
|
60
|
+
await dockerService.dockerRestart(layer);
|
61
|
+
return;
|
62
|
+
}
|
63
63
|
await this.restart();
|
64
64
|
}
|
65
65
|
async restart() {
|
package/dist/config-store.d.ts
CHANGED
@@ -63,8 +63,8 @@ export const projectHelper = {
|
|
63
63
|
async installHypergraph() {
|
64
64
|
await this.installEmbedded('hypergraph');
|
65
65
|
const { projectDir } = configStore.getProjectInfo();
|
66
|
-
// Create
|
67
|
-
const gl0DataDir = path.join(projectDir, '
|
66
|
+
// Create gl0 folders for fast forward feature before Docker does
|
67
|
+
const gl0DataDir = path.join(projectDir, 'gl0', 'data');
|
68
68
|
fs.mkdirSync(path.join(gl0DataDir, 'incremental_snapshot'), { recursive: true });
|
69
69
|
fs.mkdirSync(path.join(gl0DataDir, 'snapshot_info'));
|
70
70
|
fs.mkdirSync(path.join(gl0DataDir, 'tmp'));
|
@@ -15,7 +15,7 @@ const remoteIndexMap = {
|
|
15
15
|
export const archiverService = {
|
16
16
|
async checkLogsForMissingSnapshots() {
|
17
17
|
const { projectDir } = configStore.getProjectInfo();
|
18
|
-
const dataDir = path.join(projectDir, '
|
18
|
+
const dataDir = path.join(projectDir, 'gl0', 'logs', 'app.log');
|
19
19
|
const result = await shellService.runCommandWithOutput(`grep -i 'Global snapshot not found for ordinal' ${dataDir}`).catch(() => '');
|
20
20
|
let oldestOrdinal = Number.MAX_SAFE_INTEGER;
|
21
21
|
for (const line of result.split('\n')) {
|
@@ -46,7 +46,7 @@ export const archiverService = {
|
|
46
46
|
},
|
47
47
|
getDownloadedSnapshotRange() {
|
48
48
|
const { projectDir } = configStore.getProjectInfo();
|
49
|
-
const dataDir = path.join(projectDir, '
|
49
|
+
const dataDir = path.join(projectDir, 'gl0', 'data', 'incremental_snapshot', 'ordinal');
|
50
50
|
const result = { chunkOrdinal: 0, endOrdinal: 0, startOrdinal: 0 };
|
51
51
|
if (!fs.existsSync(dataDir)) {
|
52
52
|
return result;
|
@@ -90,7 +90,7 @@ export const archiverService = {
|
|
90
90
|
clm.preStep('Archive is not in the optimal range, but proceeding with available data.');
|
91
91
|
}
|
92
92
|
const { projectDir } = configStore.getProjectInfo();
|
93
|
-
const dataDir = path.join(projectDir, '
|
93
|
+
const dataDir = path.join(projectDir, 'gl0', 'data');
|
94
94
|
fs.mkdirSync(dataDir, { recursive: true });
|
95
95
|
clm.preStep(`Downloading latest snapshot archive ${chalk.yellow(remoteArchiveStartOrdinal)}-${chalk.yellow(remoteArchiveEndOrdinal)}; distance from cluster: ${chalk.yellow(archiveDistance)}\nCurrent oldest local ordinal: ${chalk.yellow(localStartOrdinal)}, Latest cluster ordinal: ${chalk.yellow(clusterOrdinal)}`);
|
96
96
|
// await shellService.runCommand(`curl -L ${url} -o ${dataDir}/snapshot.tar.gz`);
|
@@ -15,8 +15,8 @@ export class FastforwardService {
|
|
15
15
|
const { projectDir } = configStore.getProjectInfo();
|
16
16
|
const { type } = configStore.getNetworkInfo();
|
17
17
|
this.network = type;
|
18
|
-
this.tmpDir = path.join(projectDir, '
|
19
|
-
this.dataDir = path.join(projectDir, '
|
18
|
+
this.tmpDir = path.join(projectDir, 'gl0', 'tmp');
|
19
|
+
this.dataDir = path.join(projectDir, 'gl0', 'data');
|
20
20
|
fs.mkdirSync(this.tmpDir, { recursive: true });
|
21
21
|
fs.mkdirSync(this.dataDir, { recursive: true });
|
22
22
|
const env = configStore.getEnvNetworkInfo(type);
|
@@ -25,7 +25,15 @@ export class FastforwardService {
|
|
25
25
|
}
|
26
26
|
static async synctoLatestSnapshot() {
|
27
27
|
const ffs = new FastforwardService();
|
28
|
-
await ffs.runFastForwardSnapshot()
|
28
|
+
await ffs.runFastForwardSnapshot().catch(() => {
|
29
|
+
const { projectDir } = configStore.getProjectInfo();
|
30
|
+
const dataDir = path.join(projectDir, 'gl0', 'data', 'incremental_snapshot', 'ordinal');
|
31
|
+
if (fs.existsSync(dataDir) && fs.readdirSync(dataDir).length > 0) {
|
32
|
+
clm.warn('Failed to fast forward to latest snapshot. Skipping...');
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
clm.error('Failed to fast forward to latest snapshot. Please try again later.');
|
36
|
+
});
|
29
37
|
}
|
30
38
|
async runFastForwardSnapshot() {
|
31
39
|
const [ordinal, snapshotIncremental, snapshotInfo] = await this.fetchLatestSnapshot();
|
@@ -82,6 +90,10 @@ export class FastforwardService {
|
|
82
90
|
fs.mkdirSync(hashDir, { recursive: true });
|
83
91
|
fs.mkdirSync(ordinalDir, { recursive: true });
|
84
92
|
const destOrdinalFile = path.join(ordinalDir, ordinal);
|
93
|
+
if (fs.existsSync(destOrdinalFile)) {
|
94
|
+
clm.warn(`Snapshot ${destOrdinalFile} already exists. Skipping...`);
|
95
|
+
return;
|
96
|
+
}
|
85
97
|
fs.copyFileSync(ordinalFile, destOrdinalFile);
|
86
98
|
const hashFile = path.join(hashDir, hash);
|
87
99
|
fs.linkSync(destOrdinalFile, hashFile);
|
@@ -16,30 +16,29 @@ export const systemdService = {
|
|
16
16
|
if (!fs.existsSync(projectFolder)) {
|
17
17
|
clm.error(`Node Pilot services's folder not found: ${projectFolder}`);
|
18
18
|
}
|
19
|
+
clm.preStep('Installing Node Pilot system services...');
|
19
20
|
const restarterPath = path.join(INSTALL_PATH, 'node-pilot-restarter.service');
|
20
21
|
const updaterPath = path.join(INSTALL_PATH, 'node-pilot-updater.service');
|
21
22
|
let restarterInstalled = false;
|
22
23
|
let updaterInstalled = false;
|
23
24
|
if (!fs.existsSync(restarterPath)) {
|
24
|
-
|
25
|
+
await shellService.runCommand(`sudo cp ${path.join(projectFolder, 'node-pilot-restarter.service')} ${restarterPath}`);
|
25
26
|
clm.step('Node Pilot restarter service installed successfully.');
|
26
27
|
restarterInstalled = true;
|
27
28
|
}
|
28
29
|
if (!fs.existsSync(updaterPath)) {
|
29
|
-
|
30
|
+
await shellService.runCommand(`sudo cp ${path.join(projectFolder, 'node-pilot-updater.service')} ${updaterPath}`);
|
30
31
|
clm.step('Node Pilot updater service installed successfully.');
|
31
32
|
updaterInstalled = true;
|
32
33
|
}
|
33
34
|
if (restarterInstalled || updaterInstalled) {
|
34
|
-
await shellService.runCommand('systemctl daemon-reload');
|
35
|
-
}
|
36
|
-
if (restarterInstalled) {
|
37
|
-
await shellService.runCommand('systemctl enable node-pilot-restarter.service');
|
38
|
-
clm.step('Node Pilot restarter service enabled successfully.');
|
39
|
-
}
|
40
|
-
if (updaterInstalled) {
|
41
|
-
await shellService.runCommand('systemctl enable node-pilot-updater.service');
|
42
|
-
clm.step('Node Pilot updater service enabled successfully.');
|
35
|
+
await shellService.runCommand('sudo systemctl daemon-reload');
|
43
36
|
}
|
37
|
+
await shellService.runCommand('sudo systemctl enable node-pilot-restarter.service');
|
38
|
+
await shellService.runCommand('sudo systemctl start node-pilot-restarter.service');
|
39
|
+
clm.postStep('\nNode Pilot restarter service started successfully.');
|
40
|
+
await shellService.runCommand('sudo systemctl enable node-pilot-updater.service');
|
41
|
+
await shellService.runCommand('sudo systemctl start node-pilot-updater.service');
|
42
|
+
clm.postStep('\nNode Pilot updater service started successfully.');
|
44
43
|
}
|
45
44
|
};
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@constellation-network/node-pilot",
|
3
3
|
"description": "An easy deployment and monitoring tool for Constellation nodes.",
|
4
|
-
"version": "0.0.
|
4
|
+
"version": "0.0.12",
|
5
5
|
"author": "Frank Fox",
|
6
6
|
"bin": {
|
7
7
|
"cpilot": "bin/run.js"
|
@@ -16,7 +16,7 @@
|
|
16
16
|
"lint": "eslint",
|
17
17
|
"postpack": "shx rm -f oclif.manifest.json",
|
18
18
|
"posttest": "yarn lint",
|
19
|
-
"prepack": "oclif manifest && oclif readme",
|
19
|
+
"prepack": "npm run build && oclif manifest && oclif readme",
|
20
20
|
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
21
21
|
"version": "oclif readme && git add README.md",
|
22
22
|
"start": "./bin/dev.js",
|