@constellation-network/node-pilot 0.0.16 → 0.0.17
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
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.17 darwin-arm64 node-v24.8.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.17/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.17/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.17/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.17/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.17/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.17/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.17/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.17/src/commands/status.ts)_
|
|
233
233
|
<!-- commandsstop -->
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare function formatTime(time: number, includeSeconds: boolean): string;
|
|
2
|
+
export declare function formatTimeAgo(value: number): string | null;
|
|
1
3
|
export declare const statusTableHeader: ({
|
|
2
4
|
color: string;
|
|
3
5
|
headerColor: string;
|
|
@@ -23,6 +25,8 @@ export type NodeStatusInfo = {
|
|
|
23
25
|
clusterState: string;
|
|
24
26
|
cpuUsage: string;
|
|
25
27
|
error: string;
|
|
28
|
+
errorDate: number;
|
|
29
|
+
lastError: string;
|
|
26
30
|
memUsage: string;
|
|
27
31
|
ordinal: number;
|
|
28
32
|
pilotSession: string;
|
|
@@ -7,9 +7,9 @@ class CellFormatter {
|
|
|
7
7
|
return value;
|
|
8
8
|
if (num < 60)
|
|
9
9
|
return this.style(value.toString(), "green");
|
|
10
|
-
if (num <
|
|
10
|
+
if (num < 99)
|
|
11
11
|
return this.style(value.toString(), "yellow", "bold");
|
|
12
|
-
return this.style(value.toString(), "
|
|
12
|
+
return this.style(value.toString(), "bgRed", "bold");
|
|
13
13
|
}
|
|
14
14
|
formatDistance(value) {
|
|
15
15
|
if (value === '-')
|
|
@@ -17,8 +17,8 @@ class CellFormatter {
|
|
|
17
17
|
const num = Number(value);
|
|
18
18
|
if (num === 0)
|
|
19
19
|
return value;
|
|
20
|
-
if (num <
|
|
21
|
-
return this.style(value.toString(), "bgYellow", "bold");
|
|
20
|
+
if (num < 9)
|
|
21
|
+
return this.style(value.toString(), "bgYellow", "whiteBright", "bold");
|
|
22
22
|
return this.style(value.toString(), "bgRed", "bold");
|
|
23
23
|
}
|
|
24
24
|
formatError(value) {
|
|
@@ -41,7 +41,7 @@ class CellFormatter {
|
|
|
41
41
|
formatOrdinal(value) {
|
|
42
42
|
const [v, changed] = value.split(':');
|
|
43
43
|
if (changed) {
|
|
44
|
-
return this.style(v, "whiteBright");
|
|
44
|
+
return this.style(v, "bgCyan", "whiteBright", "bold");
|
|
45
45
|
}
|
|
46
46
|
return this.style(v, "cyan");
|
|
47
47
|
}
|
|
@@ -57,22 +57,35 @@ class CellFormatter {
|
|
|
57
57
|
return this.style(value, "white");
|
|
58
58
|
}
|
|
59
59
|
formatUpTIme(startTime) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const upTimeMs = Date.now() - Number(startTime);
|
|
63
|
-
const upTimeSec = Math.floor(upTimeMs / 1000);
|
|
64
|
-
const hours = Math.floor(upTimeSec / 3600);
|
|
65
|
-
const minutes = Math.floor((upTimeSec % 3600) / 60);
|
|
66
|
-
const seconds = upTimeSec % 60;
|
|
67
|
-
if (hours < 1 && minutes < 1)
|
|
68
|
-
return `${seconds}s`;
|
|
69
|
-
return hours > 0 ? `${hours}h ${minutes}m ${seconds}s` : `${minutes}m ${seconds}s`;
|
|
60
|
+
const formattedTime = formatTime(Date.now() - Number(startTime), true);
|
|
61
|
+
return formattedTime ?? '-';
|
|
70
62
|
}
|
|
71
|
-
style(value, color,
|
|
72
|
-
return `c${color}v${value}s${
|
|
63
|
+
style(value, color, style1, style2) {
|
|
64
|
+
return `c${color}v${value}s${style1}-${style2}`;
|
|
73
65
|
}
|
|
74
66
|
}
|
|
75
67
|
const { formatCpu, formatDistance, formatError, formatMem, formatOrdinal, formatState, formatUpTIme } = new CellFormatter();
|
|
68
|
+
export function formatTime(time, includeSeconds) {
|
|
69
|
+
if (!time)
|
|
70
|
+
return '';
|
|
71
|
+
const upTimeMs = Number(time);
|
|
72
|
+
const upTimeSec = Math.floor(upTimeMs / 1000);
|
|
73
|
+
const hours = Math.floor(upTimeSec / 3600);
|
|
74
|
+
const minutes = Math.floor((upTimeSec % 3600) / 60);
|
|
75
|
+
const seconds = upTimeSec % 60;
|
|
76
|
+
if (hours < 1 && minutes < 1)
|
|
77
|
+
return `${seconds}s`;
|
|
78
|
+
if (includeSeconds) {
|
|
79
|
+
return hours > 0 ? `${hours}h ${minutes}m ${seconds}s` : `${minutes}m ${seconds}s`;
|
|
80
|
+
}
|
|
81
|
+
return hours > 0 ? `${hours}h ${minutes}m` : `${minutes}m`;
|
|
82
|
+
}
|
|
83
|
+
export function formatTimeAgo(value) {
|
|
84
|
+
const timeAgo = formatTime(value, false);
|
|
85
|
+
if (!timeAgo)
|
|
86
|
+
return null;
|
|
87
|
+
return timeAgo + ' ago';
|
|
88
|
+
}
|
|
76
89
|
// Layer | Uptime | State | Ordinal | Distance from cluster | Cluster State | CPU Usage | Mem Usage | Error
|
|
77
90
|
export const statusTableHeader = [
|
|
78
91
|
{ color: 'white', headerColor: 'whiteBright', value: 'Network' },
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createPrompt, useKeypress } from '@inquirer/core';
|
|
2
|
+
import chalk from "chalk";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import os from "node:os";
|
|
4
5
|
import ttyTable from "tty-table";
|
|
5
6
|
import { clm } from "../clm.js";
|
|
6
7
|
import { configStore } from "../config-store.js";
|
|
7
|
-
import { statusTableHeader } from "./status-table-helper.js";
|
|
8
|
+
import { formatTimeAgo, statusTableHeader } from "./status-table-helper.js";
|
|
8
9
|
export class StatusTable {
|
|
9
10
|
alreadyRendered = false;
|
|
10
11
|
previousHeight = 0;
|
|
@@ -48,6 +49,7 @@ export class StatusTable {
|
|
|
48
49
|
async monitorState() {
|
|
49
50
|
const projects = this.getProjectInfo();
|
|
50
51
|
const values = {};
|
|
52
|
+
const err = { date: '', layer: '', msg: '', timeAgo: '' };
|
|
51
53
|
while (true) {
|
|
52
54
|
const rows = [];
|
|
53
55
|
for (const p of projects) {
|
|
@@ -71,14 +73,23 @@ export class StatusTable {
|
|
|
71
73
|
n.error || '-'
|
|
72
74
|
]);
|
|
73
75
|
values[p.layer].ordinal = n.ordinal;
|
|
76
|
+
if ((p.layer === 'gl0' || p.layer === 'ml0') && n.lastError) {
|
|
77
|
+
err.layer = p.layer.toUpperCase();
|
|
78
|
+
err.msg = n.lastError;
|
|
79
|
+
err.date = new Date(n.errorDate).toISOString();
|
|
80
|
+
err.timeAgo = formatTimeAgo(Date.now() - n.errorDate) || '';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
this.render(rows, err.msg !== '');
|
|
84
|
+
if (err.msg) {
|
|
85
|
+
process.stdout.write(chalk.green(` AUTO HEALED (${err.timeAgo}): `) + chalk.red(`${err.layer}:${err.msg} - ${err.date}\n`));
|
|
74
86
|
}
|
|
75
|
-
this.render(rows);
|
|
76
87
|
process.stdout.write(" * press any key to cancel");
|
|
77
88
|
// eslint-disable-next-line no-await-in-loop
|
|
78
89
|
await sleep(1);
|
|
79
90
|
}
|
|
80
91
|
}
|
|
81
|
-
render(rows) {
|
|
92
|
+
render(rows, hasError = false) {
|
|
82
93
|
const header = [...statusTableHeader];
|
|
83
94
|
// const emptyColumns = Array.from({length: rows[0].length}).fill(0) as number[];
|
|
84
95
|
// for (const [, row] of rows.entries()) {
|
|
@@ -102,7 +113,7 @@ export class StatusTable {
|
|
|
102
113
|
// wipe existing if already rendered
|
|
103
114
|
if (this.alreadyRendered) {
|
|
104
115
|
// move cursor up number to the top of the previous print before deleting
|
|
105
|
-
console.log(`\u001B[${this.previousHeight + 3}A`);
|
|
116
|
+
console.log(`\u001B[${this.previousHeight + (hasError ? 4 : 3)}A`);
|
|
106
117
|
// delete to end of terminal
|
|
107
118
|
console.log("\u001B[0J");
|
|
108
119
|
}
|
|
@@ -4,29 +4,25 @@ import { configStore } from "../config-store.js";
|
|
|
4
4
|
import { FastforwardService } from "./fastforward-service.js";
|
|
5
5
|
export const clusterService = {
|
|
6
6
|
async fastForwardSnapshot() {
|
|
7
|
-
const { fastForward } = configStore.getProjectInfo();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
// const { fastForward } = configStore.getProjectInfo();
|
|
8
|
+
//
|
|
9
|
+
// if (fastForward === false) {
|
|
10
|
+
// return;
|
|
11
|
+
// }
|
|
11
12
|
if (!configStore.getProjectInfo().layersToRun.includes('gl0')) {
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
|
-
if
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
configStore.setProjectInfo({ fastForward: true });
|
|
15
|
+
// if(fastForward === undefined) {
|
|
16
|
+
const answer = await input({
|
|
17
|
+
default: 'y', message: 'Do you want to use the snapshot fast forward feature? (y/n): '
|
|
18
|
+
});
|
|
19
|
+
if (answer !== 'y') {
|
|
20
|
+
configStore.setProjectInfo({ fastForward: false });
|
|
21
|
+
return;
|
|
23
22
|
}
|
|
23
|
+
configStore.setProjectInfo({ fastForward: true });
|
|
24
|
+
// }
|
|
24
25
|
await FastforwardService.synctoLatestSnapshot();
|
|
25
|
-
// await archiverService.syncToLatestSnapshot()
|
|
26
|
-
// .catch(() => {
|
|
27
|
-
// clm.warn(`Failed to download latest snapshots using Starchiver. Using fast forward to latest snapshot.`);
|
|
28
|
-
// clusterService.fastForwardSnapshot();
|
|
29
|
-
// })
|
|
30
26
|
},
|
|
31
27
|
async getClusterInfo(layer) {
|
|
32
28
|
return this.makeClusterRequest('cluster/info', layer);
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED