@constellation-network/node-pilot 0.10.1-testnet → 0.11.0-testnet

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.10.1-testnet darwin-arm64 node-v22.15.0
24
+ @constellation-network/node-pilot/0.11.0-testnet darwin-arm64 node-v22.15.0
25
25
  $ cpilot --help [COMMAND]
26
26
  USAGE
27
27
  $ cpilot COMMAND
@@ -71,7 +71,7 @@ EXAMPLES
71
71
  $ cpilot clean
72
72
  ```
73
73
 
74
- _See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.10.1-testnet/src/commands/clean.ts)_
74
+ _See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.11.0-testnet/src/commands/clean.ts)_
75
75
 
76
76
  ## `cpilot config`
77
77
 
@@ -88,7 +88,7 @@ EXAMPLES
88
88
  $ cpilot config
89
89
  ```
90
90
 
91
- _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.10.1-testnet/src/commands/config.ts)_
91
+ _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.11.0-testnet/src/commands/config.ts)_
92
92
 
93
93
  ## `cpilot config get [NAME]`
94
94
 
@@ -112,7 +112,7 @@ EXAMPLES
112
112
  $ cpilot config get gl0:CL_PUBLIC_HTTP_PORT
113
113
  ```
114
114
 
115
- _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.10.1-testnet/src/commands/config/get.ts)_
115
+ _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.11.0-testnet/src/commands/config/get.ts)_
116
116
 
117
117
  ## `cpilot config set NAME VALUE`
118
118
 
@@ -135,7 +135,7 @@ EXAMPLES
135
135
  $ cpilot config set gl0:CL_PUBLIC_HTTP_PORT 9000
136
136
  ```
137
137
 
138
- _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.10.1-testnet/src/commands/config/set.ts)_
138
+ _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.11.0-testnet/src/commands/config/set.ts)_
139
139
 
140
140
  ## `cpilot help [COMMAND]`
141
141
 
@@ -172,7 +172,7 @@ EXAMPLES
172
172
  $ cpilot info
173
173
  ```
174
174
 
175
- _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.10.1-testnet/src/commands/info.ts)_
175
+ _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.11.0-testnet/src/commands/info.ts)_
176
176
 
177
177
  ## `cpilot logs LAYER`
178
178
 
@@ -198,7 +198,7 @@ EXAMPLES
198
198
  $ cpilot logs
199
199
  ```
200
200
 
201
- _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.10.1-testnet/src/commands/logs.ts)_
201
+ _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.11.0-testnet/src/commands/logs.ts)_
202
202
 
203
203
  ## `cpilot restart [LAYER]`
204
204
 
@@ -226,7 +226,7 @@ EXAMPLES
226
226
  $ cpilot restart
227
227
  ```
228
228
 
229
- _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.10.1-testnet/src/commands/restart.ts)_
229
+ _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.11.0-testnet/src/commands/restart.ts)_
230
230
 
231
231
  ## `cpilot shutdown`
232
232
 
@@ -243,7 +243,7 @@ EXAMPLES
243
243
  $ cpilot shutdown
244
244
  ```
245
245
 
246
- _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.10.1-testnet/src/commands/shutdown.ts)_
246
+ _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.11.0-testnet/src/commands/shutdown.ts)_
247
247
 
248
248
  ## `cpilot status`
249
249
 
@@ -257,5 +257,5 @@ DESCRIPTION
257
257
  Display node status and configuration settings
258
258
  ```
259
259
 
260
- _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.10.1-testnet/src/commands/status.ts)_
260
+ _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.11.0-testnet/src/commands/status.ts)_
261
261
  <!-- commandsstop -->
@@ -140,6 +140,7 @@ export const checkNetwork = {
140
140
  return shellService.runCommandWithOutput('curl -4 https://ifconfig.me/ip');
141
141
  },
142
142
  async isNetworkConnectable() {
143
+ const { type } = configStore.getNetworkInfo();
143
144
  return clusterService.getClusterInfo()
144
145
  .then(async (nodes) => {
145
146
  const someAreReady = nodes.some(node => node.state === 'Ready');
@@ -149,12 +150,12 @@ export const checkNetwork = {
149
150
  }
150
151
  throw new Error(`Network is not connectable.`);
151
152
  }
152
- clm.debug(`Network is live. Found ${nodes.length} nodes in the cluster.`);
153
+ clm.debug(`${type} is live. Found ${nodes.length} nodes in the cluster.`);
153
154
  configStore.setClusterStats({ total: nodes.length });
154
155
  return true;
155
156
  })
156
157
  .catch(() => {
157
- clm.error(`Network is not in service. Please try again later.`);
158
+ clm.error(`${type} is not in service. Please try again later.`);
158
159
  return false;
159
160
  });
160
161
  }
@@ -1,5 +1,6 @@
1
1
  import { input, number, select } from "@inquirer/prompts";
2
2
  import os from "node:os";
3
+ import ora from "ora";
3
4
  import { clm } from "../clm.js";
4
5
  import { configStore } from "../config-store.js";
5
6
  import { configHelper } from "../helpers/config-helper.js";
@@ -149,35 +150,28 @@ export const checkProject = {
149
150
  if (isRunning) {
150
151
  await dockerService.dockerDown();
151
152
  }
152
- // const silent = !process.env.DEBUG;
153
- //
154
- // const spinner = ora('');
155
- //
156
- // if (silent) {
157
- // spinner.start();
158
- // spinner.color = 'green';
159
- // }
160
- // else {
161
- if (!rInfo && !configStore.isRestarting()) {
162
- // First time install
163
- clm.preStep('Tessellation and dependencies need to be installed. This may take a few minutes...');
164
- await promptHelper.doYouWishToContinue();
153
+ const showSpinner = !configStore.isRestarting();
154
+ const spinner = ora('');
155
+ if (showSpinner) {
156
+ spinner.start();
157
+ spinner.color = 'green';
165
158
  }
159
+ // if (!rInfo && !configStore.isRestarting()) {
160
+ // // First time install
161
+ // clm.preStep('Tessellation and dependencies need to be installed. This may take a few minutes...');
162
+ // await promptHelper.doYouWishToContinue();
166
163
  // }
167
- // const node = await clusterService.getClusterNodeInfo();
168
- // const NODE_URL = `http://${node.host}:${node.publicPort}`;
169
164
  // NOTE: may be different for metagraphs
170
165
  await shellService.runProjectCommand(`scripts/install.sh ${nInfo.type}`, undefined, false)
171
166
  .catch(() => {
172
- // spinner.stop();
173
- // if (silent) {
174
- // clm.error(`Install script failed. run: ${chalk.cyan("DEBUG=true cpilot")} for more details`);
175
- // }
167
+ if (showSpinner) {
168
+ spinner.stop();
169
+ }
176
170
  clm.error('Install script failed. Please run cpilot again after correcting the error');
177
171
  });
178
- // if (silent) {
179
- // spinner.stop();
180
- // }
172
+ if (showSpinner) {
173
+ spinner.stop();
174
+ }
181
175
  rInfo = await configHelper.getReleaseInfo();
182
176
  configStore.setNetworkInfo({
183
177
  type: rInfo.network,
@@ -1,10 +1,6 @@
1
1
  import { Args, Command, Flags } from '@oclif/core';
2
- import { clm } from "../clm.js";
3
2
  import { configStore } from "../config-store.js";
4
3
  import { projectHelper } from "../helpers/project-helper.js";
5
- import { promptHelper } from "../helpers/prompt-helper.js";
6
- import { dockerService } from "../services/docker-service.js";
7
- import { shellService } from "../services/shell-service.js";
8
4
  export default class Clean extends Command {
9
5
  static args = {
10
6
  layer: Args.string({ description: 'network layer to clean. e.g. gl0', required: false }),
@@ -29,30 +25,6 @@ export default class Clean extends Command {
29
25
  const deleteLogs = flags.logs || deleteAll;
30
26
  const deleteData = flags.data || deleteAll;
31
27
  const deleteJars = flags.jars || deleteAll;
32
- if (await dockerService.isRunning()) {
33
- clm.preStep('The validator node must be stopped first.');
34
- await promptHelper.doYouWishToContinue();
35
- await dockerService.dockerDown();
36
- }
37
- clm.preStep('Requesting sudo permission to remove files...');
38
- for (const layer of layers) {
39
- if (deleteData) {
40
- // eslint-disable-next-line no-await-in-loop
41
- await shellService.runProjectCommand(`sudo rm -rf ${layer}/data`);
42
- if (layer === 'gl0') {
43
- projectHelper.prepareDataFolder();
44
- configStore.setProjectFlag('discordChecked', false);
45
- }
46
- }
47
- if (deleteLogs) {
48
- // eslint-disable-next-line no-await-in-loop
49
- await shellService.runProjectCommand(`sudo rm -rf ${layer}/logs`);
50
- }
51
- if (deleteJars) {
52
- // eslint-disable-next-line no-await-in-loop
53
- await shellService.runProjectCommand(`sudo rm -rf ${layer}/dist`);
54
- }
55
- }
56
- clm.postStep('Done');
28
+ await projectHelper.cleanup(layers, deleteLogs, deleteData, deleteJars);
57
29
  }
58
30
  }
@@ -1,13 +1,14 @@
1
1
  import { select } from '@inquirer/prompts';
2
2
  import { Command } from '@oclif/core';
3
3
  import { checkNetwork } from "../checks/check-network.js";
4
+ import { checkNodePilot } from "../checks/check-pilot.js";
4
5
  import { checkProject } from "../checks/check-project.js";
5
6
  import { clm } from "../clm.js";
7
+ import { configStore } from "../config-store.js";
6
8
  import { configHelper } from "../helpers/config-helper.js";
7
9
  import { keyFileHelper } from "../helpers/key-file-helper.js";
10
+ import { projectHelper } from "../helpers/project-helper.js";
8
11
  import { promptHelper } from "../helpers/prompt-helper.js";
9
- import { dockerService } from "../services/docker-service.js";
10
- import { checkNodePilot } from "../checks/check-pilot.js";
11
12
  export default class Config extends Command {
12
13
  static description = 'Update configuration settings';
13
14
  static examples = [
@@ -36,30 +37,27 @@ export default class Config extends Command {
36
37
  await checkNodePilot.promptDiscordRegistration();
37
38
  }
38
39
  else if (answer === 'javaMemory') {
39
- await shutdownNodeIfRunning();
40
+ await promptHelper.shutdownNodeIfRunning();
40
41
  await checkProject.configureJavaMemoryArguments();
41
42
  }
42
43
  else if (answer === 'keyFile') {
43
- await shutdownNodeIfRunning();
44
+ await promptHelper.shutdownNodeIfRunning();
44
45
  await keyFileHelper.showKeyFileInfo();
45
46
  await keyFileHelper.promptForKeyFile();
46
47
  }
47
48
  else if (answer === 'layersToRun') {
48
- await shutdownNodeIfRunning();
49
+ await promptHelper.shutdownNodeIfRunning();
49
50
  await promptHelper.selectLayers();
50
51
  await checkProject.configureJavaMemoryArguments();
51
52
  }
52
53
  else if (answer === 'network') {
53
- await shutdownNodeIfRunning();
54
+ clm.warn('Changing the network will DELETE all the data and logs from the validator node.');
55
+ await promptHelper.doYouWishToContinue();
56
+ const { layersToRun } = configStore.getProjectInfo();
57
+ await projectHelper.cleanup(layersToRun, true, true, true);
54
58
  await promptHelper.selectNetwork();
59
+ await checkNodePilot.checkVersion(); // each network may have its own release
55
60
  await checkProject.runInstall();
56
61
  }
57
62
  }
58
63
  }
59
- async function shutdownNodeIfRunning() {
60
- if (await dockerService.isRunning()) {
61
- clm.preStep('The validator node must be stopped first.');
62
- await promptHelper.doYouWishToContinue();
63
- await dockerService.dockerDown();
64
- }
65
- }
@@ -96,6 +96,10 @@ export default class Restart extends BaseCommand {
96
96
  serviceLog.log('Restart already ACTIVE');
97
97
  process.exit(0);
98
98
  }
99
+ process.on("exit", () => {
100
+ // serviceLog.log('exiting, clearing isRestarting flag');
101
+ configStore.setIsRestarting(0);
102
+ });
99
103
  configStore.setIsRestarting(Date.now());
100
104
  }
101
105
  else {
@@ -1,5 +1,6 @@
1
1
  import { TessellationLayer } from "../types.js";
2
2
  export declare const projectHelper: {
3
+ cleanup(layers: TessellationLayer[], deleteData: boolean, deleteLogs: boolean, deleteJars: boolean): Promise<void>;
3
4
  generateLayerEnvFiles(layers?: TessellationLayer[]): Promise<void>;
4
5
  importEnvFiles(): void;
5
6
  installEmbedded(name: string): Promise<void>;
@@ -9,7 +9,31 @@ import { githubService } from "../services/github-service.js";
9
9
  import { shellService } from "../services/shell-service.js";
10
10
  import { configHelper } from "./config-helper.js";
11
11
  import { getLayerEnvFileContent } from "./env-templates.js";
12
+ import { promptHelper } from "./prompt-helper.js";
12
13
  export const projectHelper = {
14
+ async cleanup(layers, deleteData, deleteLogs, deleteJars) {
15
+ await promptHelper.shutdownNodeIfRunning();
16
+ clm.preStep('Requesting sudo permission to remove files...');
17
+ for (const layer of layers) {
18
+ if (deleteData) {
19
+ // eslint-disable-next-line no-await-in-loop
20
+ await shellService.runProjectCommand(`sudo rm -rf ${layer}/data`);
21
+ if (layer === 'gl0') {
22
+ this.prepareDataFolder();
23
+ configStore.setProjectFlag('discordChecked', false);
24
+ }
25
+ }
26
+ if (deleteLogs) {
27
+ // eslint-disable-next-line no-await-in-loop
28
+ await shellService.runProjectCommand(`sudo rm -rf ${layer}/logs`);
29
+ }
30
+ if (deleteJars) {
31
+ // eslint-disable-next-line no-await-in-loop
32
+ await shellService.runProjectCommand(`sudo rm -rf ${layer}/dist`);
33
+ }
34
+ }
35
+ clm.postStep('Cleanup complete');
36
+ },
13
37
  async generateLayerEnvFiles(layers) {
14
38
  const { layersToRun, projectDir } = configStore.getProjectInfo();
15
39
  const { type: network } = configStore.getNetworkInfo();
@@ -3,4 +3,5 @@ export declare const promptHelper: {
3
3
  doYouWishToContinue(defaultAnswer?: "n" | "y"): Promise<void>;
4
4
  selectLayers(): Promise<void>;
5
5
  selectNetwork(): Promise<void>;
6
+ shutdownNodeIfRunning(): Promise<void>;
6
7
  };
@@ -1,6 +1,9 @@
1
1
  import { checkbox, input, select } from "@inquirer/prompts";
2
2
  import chalk from "chalk";
3
+ import { clm } from "../clm.js";
3
4
  import { configStore } from "../config-store.js";
5
+ import { dockerService } from "../services/docker-service.js";
6
+ import { nodeService } from "../services/node-service.js";
4
7
  export const promptHelper = {
5
8
  async confirmPrompt(msg) {
6
9
  const result = await input({
@@ -57,5 +60,14 @@ export const promptHelper = {
57
60
  configStore.setNetworkInfo({ type: networkType, version: "latest" });
58
61
  configStore.setProjectFlag('duplicateNodeIdChecked', false);
59
62
  configStore.setProjectFlag('seedListChecked', false);
63
+ configStore.setProjectFlag('javaMemoryChecked', false);
64
+ },
65
+ async shutdownNodeIfRunning() {
66
+ if (await dockerService.isRunning()) {
67
+ clm.preStep('The validator node must be stopped first.');
68
+ await promptHelper.doYouWishToContinue();
69
+ await nodeService.leaveClusterAllLayers().catch();
70
+ await dockerService.dockerDown();
71
+ }
60
72
  }
61
73
  };
@@ -1,4 +1,5 @@
1
1
  import { input } from "@inquirer/prompts";
2
+ import ora from "ora";
2
3
  import { clm } from "../clm.js";
3
4
  import { configStore } from "../config-store.js";
4
5
  import { FastforwardService } from "./fastforward-service.js";
@@ -22,7 +23,11 @@ export const clusterService = {
22
23
  }
23
24
  configStore.setProjectInfo({ fastForward: true });
24
25
  // }
26
+ const spinner = ora('Downloading latest snapshot...');
27
+ spinner.start();
28
+ spinner.color = 'green';
25
29
  await FastforwardService.synctoLatestSnapshot();
30
+ spinner.stop();
26
31
  },
27
32
  async getClusterInfo(layer) {
28
33
  return this.makeClusterRequest('cluster/info', layer);
@@ -340,5 +340,5 @@
340
340
  ]
341
341
  }
342
342
  },
343
- "version": "0.10.1-testnet"
343
+ "version": "0.11.0-testnet"
344
344
  }
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.10.1-testnet",
4
+ "version": "0.11.0-testnet",
5
5
  "author": "Frank Fox",
6
6
  "bin": {
7
7
  "cpilot": "bin/run.js"
@@ -39,7 +39,7 @@ COPY dist/gl0.jar /app/jars/gl0.jar
39
39
  #COPY ./health-check /health-check
40
40
  #RUN chmod +x /health-check/bin/run.sh
41
41
  #RUN chmod +x /health-check/bin/hydrate.sh
42
- RUN npm install -g "@constellation-network/node-pilot-health-check@0.0.24"
42
+ RUN npm install -g "@constellation-network/node-pilot-health-check@0.0.25"
43
43
 
44
44
  # Add entrypoint
45
45
  COPY ./entrypoint.sh /app/entrypoint.sh