@constellation-network/node-pilot 0.0.9 → 0.0.10

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.9 darwin-arm64 node-v22.15.0
24
+ @constellation-network/node-pilot/0.0.10 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.9/src/commands/config.ts)_
65
+ _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.10/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.9/src/commands/config/get.ts)_
89
+ _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.10/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.9/src/commands/config/set.ts)_
112
+ _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.10/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.9/src/commands/info.ts)_
149
+ _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.10/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.9/src/commands/logs.ts)_
173
+ _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.10/src/commands/logs.ts)_
174
174
 
175
175
  ## `cpilot restart [LAYER]`
176
176
 
@@ -178,14 +178,18 @@ A full shutdown of the validator node, then restart
178
178
 
179
179
  ```
180
180
  USAGE
181
- $ cpilot restart [LAYER] [-p hypergraph]
181
+ $ cpilot restart [LAYER] [-p ] [--autostart] [--update]
182
182
 
183
183
  ARGUMENTS
184
- LAYER network layer to view. e.g. gl0
184
+ LAYER network layer to restart. e.g. gl0
185
+
186
+ FLAGS
187
+ --autostart restart each running project if it has been stopped
188
+ --update update each project if a new version is available
185
189
 
186
190
  GLOBAL FLAGS
187
191
  -p, --project=<option> Specify the project name to use
188
- <options: hypergraph>
192
+ <options: >
189
193
 
190
194
  DESCRIPTION
191
195
  A full shutdown of the validator node, then restart
@@ -194,7 +198,7 @@ EXAMPLES
194
198
  $ cpilot restart
195
199
  ```
196
200
 
197
- _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.9/src/commands/restart.ts)_
201
+ _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.10/src/commands/restart.ts)_
198
202
 
199
203
  ## `cpilot shutdown`
200
204
 
@@ -211,7 +215,7 @@ EXAMPLES
211
215
  $ cpilot shutdown
212
216
  ```
213
217
 
214
- _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.9/src/commands/shutdown.ts)_
218
+ _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.10/src/commands/shutdown.ts)_
215
219
 
216
220
  ## `cpilot status`
217
221
 
@@ -225,5 +229,5 @@ DESCRIPTION
225
229
  Display node status and configuration settings
226
230
  ```
227
231
 
228
- _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.9/src/commands/status.ts)_
232
+ _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.10/src/commands/status.ts)_
229
233
  <!-- commandsstop -->
@@ -14,7 +14,7 @@ export class BaseCommand extends Command {
14
14
  checkProject(flags) {
15
15
  configHelper.assertProject('No project found. ');
16
16
  if (flags.project) {
17
- configStore.changeProjectStore(flags.project);
17
+ configStore.setActiveProject(flags.project);
18
18
  }
19
19
  }
20
20
  }
@@ -1,5 +1,6 @@
1
1
  import chalk from "chalk";
2
2
  import { configStore } from "../config-store.js";
3
+ import { systemdService } from "../services/systemd-service.js";
3
4
  import { checkDependencies } from "./check-dependencies.js";
4
5
  import { checkHardware } from "./check-hardware.js";
5
6
  export const checkInitialSetup = {
@@ -13,5 +14,6 @@ export const checkInitialSetup = {
13
14
  console.log(" " + chalk.whiteBright("NODE PILOT") + " ");
14
15
  console.log(chalk.whiteBright(" ****************************************"));
15
16
  await checkHardware.systemRequirements();
17
+ await systemdService.install();
16
18
  },
17
19
  };
@@ -1,4 +1,5 @@
1
1
  export declare const checkProject: {
2
+ hasVersionChanged(): Promise<boolean>;
2
3
  projectInstallation(): Promise<void>;
3
4
  releaseVersion(): Promise<void>;
4
5
  runInstall(): Promise<boolean>;
@@ -11,6 +11,11 @@ import { dockerService } from "../services/docker-service.js";
11
11
  import { shellService } from "../services/shell-service.js";
12
12
  import { checkNetwork } from "./check-network.js";
13
13
  export const checkProject = {
14
+ async hasVersionChanged() {
15
+ const clusterVersion = await clusterService.getReleaseVersion();
16
+ const rInfo = await configHelper.getReleaseInfo();
17
+ return !rInfo || (rInfo.version !== clusterVersion);
18
+ },
14
19
  async projectInstallation() {
15
20
  let updateNetworkType = false;
16
21
  let updateLayers = false;
@@ -81,11 +86,10 @@ export const checkProject = {
81
86
  },
82
87
  async runInstall() {
83
88
  const nInfo = configStore.getNetworkInfo();
84
- const node = await clusterService.getClusterNodeInfo();
85
- const NODE_URL = `http://${node.host}:${node.publicPort}`;
89
+ const clusterVersion = await clusterService.getReleaseVersion();
86
90
  let rInfo = await configHelper.getReleaseInfo();
87
- if (rInfo && rInfo.network === nInfo.type && rInfo.version === node.version) {
88
- clm.postStep(`Network files are already installed for ${nInfo.type} version ${node.version}`);
91
+ if (rInfo && rInfo.network === nInfo.type && rInfo.version === clusterVersion) {
92
+ clm.postStep(`Network files are already installed for ${nInfo.type} version ${clusterVersion}`);
89
93
  return false;
90
94
  }
91
95
  const isRunning = await dockerService.isRunning();
@@ -101,8 +105,10 @@ export const checkProject = {
101
105
  else {
102
106
  clm.preStep('Running install script...');
103
107
  }
108
+ // const node = await clusterService.getClusterNodeInfo();
109
+ // const NODE_URL = `http://${node.host}:${node.publicPort}`;
104
110
  // NOTE: may be different for metagraphs
105
- await shellService.runProjectCommand(`scripts/install.sh ${nInfo.type}`, { NODE_URL }, silent)
111
+ await shellService.runProjectCommand(`scripts/install.sh ${nInfo.type}`, undefined, silent)
106
112
  .catch(() => {
107
113
  spinner.stop();
108
114
  if (silent) {
@@ -5,5 +5,10 @@ export default class Restart extends BaseCommand {
5
5
  };
6
6
  static description: string;
7
7
  static examples: string[];
8
+ static flags: {
9
+ autostart: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ update: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
8
12
  run(): Promise<void>;
13
+ private restart;
9
14
  }
@@ -1,4 +1,4 @@
1
- import { Args } from '@oclif/core';
1
+ import { Args, Flags } from '@oclif/core';
2
2
  import { BaseCommand } from "../base-command.js";
3
3
  import { checkProject } from "../checks/check-project.js";
4
4
  import { clm } from "../clm.js";
@@ -8,21 +8,25 @@ import { dockerService } from "../services/docker-service.js";
8
8
  import { nodeService } from "../services/node-service.js";
9
9
  export default class Restart extends BaseCommand {
10
10
  static args = {
11
- layer: Args.string({ description: 'network layer to view. e.g. gl0' }),
11
+ layer: Args.string({ description: 'network layer to restart. e.g. gl0' }),
12
12
  };
13
13
  static description = 'A full shutdown of the validator node, then restart';
14
14
  static examples = [
15
15
  '<%= config.bin %> <%= command.id %>',
16
16
  ];
17
+ static flags = {
18
+ autostart: Flags.boolean({ description: 'restart each running project if it has been stopped' }),
19
+ update: Flags.boolean({ description: 'update each project if a new version is available' }),
20
+ };
17
21
  async run() {
18
22
  const { args, flags } = await this.parse(Restart);
19
23
  this.checkProject(flags);
20
24
  configHelper.assertProject('No project found. ');
21
- const { layersToRun } = configStore.getProjectInfo();
22
25
  if (!await dockerService.isRunning()) {
23
26
  this.error('The validator node is not running.');
24
27
  }
25
28
  if (args && args.layer) {
29
+ const { layersToRun } = configStore.getProjectInfo();
26
30
  const layer = args.layer;
27
31
  if (!layersToRun.includes(layer)) {
28
32
  this.error(`Invalid layer: ${layer}. Available layers: ${layersToRun.join(',')}`);
@@ -33,10 +37,42 @@ export default class Restart extends BaseCommand {
33
37
  await dockerService.dockerRestart(layer);
34
38
  return;
35
39
  }
36
- await nodeService.leaveClusterAllLayers();
37
- await nodeService.pollForLayersState(layersToRun, 'Offline');
38
- clm.preStep('Stopping the node...');
39
- await dockerService.dockerDown();
40
+ if (flags.update) {
41
+ const project = configStore.getActiveProject();
42
+ for (const project of configStore.getRunningProjects()) {
43
+ configStore.setActiveProject(project);
44
+ // eslint-disable-next-line no-await-in-loop
45
+ if (await checkProject.hasVersionChanged()) {
46
+ // eslint-disable-next-line no-await-in-loop
47
+ await this.restart();
48
+ }
49
+ }
50
+ configStore.setActiveProject(project);
51
+ return;
52
+ }
53
+ if (flags.autostart) {
54
+ const project = configStore.getActiveProject();
55
+ for (const project of configStore.getRunningProjects()) {
56
+ configStore.setActiveProject(project);
57
+ // eslint-disable-next-line no-await-in-loop
58
+ await this.restart();
59
+ }
60
+ configStore.setActiveProject(project);
61
+ return;
62
+ }
63
+ await this.restart();
64
+ }
65
+ async restart() {
66
+ // const pAll = layersToRun.map(l => nodeService.getNodeInfo(l));
67
+ // const info = await Promise.all(pAll);
68
+ // const isRunning = info.some(n => n.state !== 'Unavailable');
69
+ if (await dockerService.isRunning()) {
70
+ await nodeService.leaveClusterAllLayers();
71
+ const { layersToRun } = configStore.getProjectInfo();
72
+ await nodeService.pollForLayersState(layersToRun, 'Offline');
73
+ clm.preStep('Stopping the node...');
74
+ await dockerService.dockerDown();
75
+ }
40
76
  clm.preStep('Checking for a new version...');
41
77
  await checkProject.runUpgrade();
42
78
  clm.preStep('Starting the node...');
@@ -3,7 +3,6 @@ import dotenv from "dotenv";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
- import { archiverService } from "../services/archiver-service.js";
7
6
  import { getRandomNode } from "../services/get-random-node.js";
8
7
  export default class Test extends Command {
9
8
  static description = 'node pilot test command';
@@ -17,7 +16,7 @@ export default class Test extends Command {
17
16
  // console.log(ordinal)
18
17
  //
19
18
  // await archiverService.syncToLatestSnapshot();
20
- await archiverService.checkLogsForMissingSnapshots();
19
+ // await archiverService.checkLogsForMissingSnapshots();
21
20
  }
22
21
  async testRandomNode() {
23
22
  const filePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../projects/hypergraph/networks/mainnet/source-nodes.env`);
@@ -4,7 +4,7 @@ declare class ConfigStore {
4
4
  private projectStore;
5
5
  constructor();
6
6
  applyNewProjectStore(name: string): Promise<void>;
7
- changeProjectStore(name: string): void;
7
+ getActiveProject(): string;
8
8
  getAppDir(): string;
9
9
  getDockerEnvInfo(): object;
10
10
  getEnvInfo(): EnvInfo;
@@ -14,9 +14,11 @@ declare class ConfigStore {
14
14
  getNetworkInfo(): NetworkInfo;
15
15
  getProjectInfo(): ProjectInfo;
16
16
  getProjects(): string[];
17
+ getRunningProjects(): string[];
17
18
  getSystemInfo(): SystemInfo;
18
19
  hasProjectFlag(name: string): any;
19
20
  hasProjects(): boolean;
21
+ setActiveProject(name: string): void;
20
22
  setClusterStats(info: Partial<ClusterStats>): void;
21
23
  setDockerEnvInfo(info: Partial<{
22
24
  DOCKER_IMAGE_VERSION: string;
@@ -28,6 +30,7 @@ declare class ConfigStore {
28
30
  setNetworkInfo(info: Partial<NetworkInfo>): void;
29
31
  setProjectFlag(name: string, value: boolean): any;
30
32
  setProjectInfo(info: Partial<ProjectInfo>): void;
33
+ setProjectStatusToRunning(isRunning: boolean): void;
31
34
  setSystemInfo(info: Partial<SystemInfo>): void;
32
35
  private getPilotInfo;
33
36
  private setPilotInfo;
@@ -15,12 +15,12 @@ class ConfigStore {
15
15
  constructor() {
16
16
  const appDir = path.join(os.homedir(), '.node-pilot');
17
17
  if (!fs.existsSync(appDir)) {
18
- fs.mkdirSync(appDir, { recursive: true });
18
+ fs.mkdirSync(path.join(appDir, 'logs'), { recursive: true });
19
19
  }
20
20
  this.pilotStore = new JSONStorage(path.join(appDir, 'config'));
21
21
  const appInfo = this.pilotStore.getItem('pilot');
22
22
  if (!appInfo) {
23
- this.pilotStore.setItem('pilot', { appDir, project: 'undefined', projects: [] });
23
+ this.pilotStore.setItem('pilot', { appDir, project: 'undefined', projects: [], running: [] });
24
24
  }
25
25
  const { project } = this.pilotStore.getItem('pilot');
26
26
  this.projectStore = project === 'undefined' ? new EmptyStorage() : new JSONStorage(path.join(appDir, project, 'config'));
@@ -48,17 +48,9 @@ class ConfigStore {
48
48
  this.setDockerEnvInfo({ DOCKER_IMAGE_VERSION: 'test' });
49
49
  this.setProjectInfo({ name, projectDir });
50
50
  }
51
- changeProjectStore(name) {
52
- const { appDir, project, projects } = this.pilotStore.getItem('pilot');
53
- if (projects && projects.includes(name)) {
54
- if (project === name)
55
- return;
56
- this.projectStore = new JSONStorage(path.join(appDir, name, 'config'));
57
- this.setPilotInfo({ project: name });
58
- }
59
- else {
60
- throw new Error(`Project ${name} doesn't exist.`);
61
- }
51
+ getActiveProject() {
52
+ const { project } = this.pilotStore.getItem('pilot');
53
+ return project;
62
54
  }
63
55
  getAppDir() {
64
56
  const { appDir } = this.pilotStore.getItem('pilot');
@@ -97,6 +89,10 @@ class ConfigStore {
97
89
  const { projects } = this.pilotStore.getItem('pilot');
98
90
  return projects;
99
91
  }
92
+ getRunningProjects() {
93
+ const { running } = this.pilotStore.getItem('pilot');
94
+ return running;
95
+ }
100
96
  getSystemInfo() {
101
97
  return this.pilotStore.getItem('system');
102
98
  }
@@ -108,10 +104,18 @@ class ConfigStore {
108
104
  const { projects } = this.pilotStore.getItem('pilot');
109
105
  return projects.length > 0;
110
106
  }
111
- // setCurrentEnvNetworkInfo(info: Partial<EnvNetworkInfo>) {
112
- // const {type} = this.getNetworkInfo();
113
- // this.setEnvNetworkInfo(type, info);
114
- // }
107
+ setActiveProject(name) {
108
+ const { appDir, project, projects } = this.pilotStore.getItem('pilot');
109
+ if (projects && projects.includes(name)) {
110
+ if (project === name)
111
+ return;
112
+ this.projectStore = new JSONStorage(path.join(appDir, name, 'config'));
113
+ this.setPilotInfo({ project: name });
114
+ }
115
+ else {
116
+ throw new Error(`Project ${name} doesn't exist.`);
117
+ }
118
+ }
115
119
  setClusterStats(info) {
116
120
  const oldInfo = this.projectStore.getItem('cluster-stats');
117
121
  this.projectStore.setItem('cluster-stats', { ...oldInfo, ...info });
@@ -152,6 +156,20 @@ class ConfigStore {
152
156
  const oldInfo = this.projectStore.getItem('project');
153
157
  this.projectStore.setItem('project', { ...oldInfo, ...info });
154
158
  }
159
+ setProjectStatusToRunning(isRunning) {
160
+ const { project, running } = this.pilotStore.getItem('pilot');
161
+ if (isRunning) {
162
+ if (running.includes(project))
163
+ return;
164
+ this.setPilotInfo({ running: [...running, project] });
165
+ }
166
+ else {
167
+ if (!running.includes(project))
168
+ return;
169
+ running.splice(running.indexOf(project), 1);
170
+ this.setPilotInfo({ running });
171
+ }
172
+ }
155
173
  setSystemInfo(info) {
156
174
  const oldInfo = this.projectStore.getItem('system');
157
175
  this.pilotStore.setItem('system', { ...oldInfo, ...info });
@@ -24,6 +24,7 @@ export const dockerService = {
24
24
  },
25
25
  async dockerDown() {
26
26
  await run('down');
27
+ configStore.setProjectStatusToRunning(false);
27
28
  },
28
29
  async dockerRestart(layer) {
29
30
  await run('restart', [layer]);
@@ -37,13 +38,11 @@ export const dockerService = {
37
38
  await this.dockerDown();
38
39
  }
39
40
  await projectHelper.generateLayerEnvFiles();
40
- // const userId = await shellService.runCommandWithOutput('echo "$(id -u):$(id -g)"')
41
- // console.log('Setting DOCKER_USER_ID to', userId);
42
- // configStore.setDockerEnvInfo({ DOCKER_USER_ID: userId });
43
41
  await run('up -d');
42
+ configStore.setProjectStatusToRunning(true);
44
43
  },
45
44
  async isRunning() {
46
- return shellService.runCommand('docker ps | grep entrypoint.sh', undefined, true).then(Boolean).catch(() => false);
45
+ return shellService.runProjectCommand('docker compose ps -q | grep .', undefined, true).then(Boolean).catch(() => false);
47
46
  }
48
47
  };
49
48
  function run(command, layers) {
@@ -0,0 +1 @@
1
+ export declare const notifyService: {};
@@ -0,0 +1 @@
1
+ export const notifyService = {};
@@ -0,0 +1,3 @@
1
+ export declare const systemdService: {
2
+ install(): Promise<void>;
3
+ };
@@ -0,0 +1,45 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { clm } from "../clm.js";
5
+ import { configStore } from "../config-store.js";
6
+ import { shellService } from "./shell-service.js";
7
+ const INSTALL_PATH = '/etc/systemd/system/';
8
+ export const systemdService = {
9
+ async install() {
10
+ const { platform } = configStore.getSystemInfo();
11
+ if (platform !== 'linux') {
12
+ clm.warn('Node Pilot services can only be installed on Linux systems. Skipping systemd service installation.\n');
13
+ return;
14
+ }
15
+ const projectFolder = path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../scripts/services`);
16
+ if (!fs.existsSync(projectFolder)) {
17
+ clm.error(`Node Pilot services's folder not found: ${projectFolder}`);
18
+ }
19
+ const restarterPath = path.join(INSTALL_PATH, 'node-pilot-restarter.service');
20
+ const updaterPath = path.join(INSTALL_PATH, 'node-pilot-updater.service');
21
+ let restarterInstalled = false;
22
+ let updaterInstalled = false;
23
+ if (!fs.existsSync(restarterPath)) {
24
+ fs.cpSync(path.join(projectFolder, 'node-pilot-restarter.service'), path.join(INSTALL_PATH, 'node-pilot-restarter.service'));
25
+ clm.step('Node Pilot restarter service installed successfully.');
26
+ restarterInstalled = true;
27
+ }
28
+ if (!fs.existsSync(updaterPath)) {
29
+ fs.cpSync(path.join(projectFolder, 'node-pilot-updater.service'), path.join(INSTALL_PATH, 'node-pilot-updater.service'));
30
+ clm.step('Node Pilot updater service installed successfully.');
31
+ updaterInstalled = true;
32
+ }
33
+ 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.');
43
+ }
44
+ }
45
+ };
@@ -95,7 +95,7 @@
95
95
  "aliases": [],
96
96
  "args": {
97
97
  "layer": {
98
- "description": "network layer to view. e.g. gl0",
98
+ "description": "network layer to restart. e.g. gl0",
99
99
  "name": "layer"
100
100
  }
101
101
  },
@@ -111,10 +111,20 @@
111
111
  "name": "project",
112
112
  "hasDynamicHelp": false,
113
113
  "multiple": false,
114
- "options": [
115
- "hypergraph"
116
- ],
114
+ "options": [],
117
115
  "type": "option"
116
+ },
117
+ "autostart": {
118
+ "description": "restart each running project if it has been stopped",
119
+ "name": "autostart",
120
+ "allowNo": false,
121
+ "type": "boolean"
122
+ },
123
+ "update": {
124
+ "description": "update each project if a new version is available",
125
+ "name": "update",
126
+ "allowNo": false,
127
+ "type": "boolean"
118
128
  }
119
129
  },
120
130
  "hasDynamicHelp": false,
@@ -264,5 +274,5 @@
264
274
  ]
265
275
  }
266
276
  },
267
- "version": "0.0.9"
277
+ "version": "0.0.10"
268
278
  }
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.9",
4
+ "version": "0.0.10",
5
5
  "author": "Frank Fox",
6
6
  "bin": {
7
7
  "cpilot": "bin/run.js"
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "custom",
3
+ "projects": [
4
+ { "name": "hg-intnet-1", "network": "intnet", "key": "key1.p12", "layers": "gl0" },
5
+ { "name": "hg-intnet-2", "network": "intnet", "key": "key2.p12", "layers": "gl0" },
6
+ { "name": "hg-intnet-3", "network": "intnet", "key": "key3.p12", "layers": "gl0" }
7
+ ]
8
+ }
9
+
@@ -36,9 +36,6 @@ COPY dist/gl1.jar /app/jars/gl1.jar
36
36
  COPY dist/gl0.jar /app/jars/gl0.jar
37
37
 
38
38
  # Add health-check
39
- #COPY ./health-check /health-check
40
- #RUN chmod +x /health-check/bin/run.sh
41
- #RUN chmod +x /health-check/bin/hydrate.sh
42
39
  RUN npm install -g "@constellation-network/node-pilot-health-check"
43
40
 
44
41
  # Add entrypoint
@@ -9,7 +9,6 @@ services:
9
9
  - /var/run/docker.sock:/var/run/docker.sock
10
10
  gl0:
11
11
  image: constellationnetwork/tessellation${CL_DOCKER_CORE_REPO:-}:${DOCKER_IMAGE_VERSION:-latest}
12
- container_name: gl0
13
12
  networks:
14
13
  - tessellation-network
15
14
  restart: unless-stopped
@@ -34,7 +33,6 @@ services:
34
33
  autoheal: "true"
35
34
  gl1:
36
35
  image: constellationnetwork/tessellation${CL_DOCKER_CORE_REPO:-}:${DOCKER_IMAGE_VERSION:-latest}
37
- container_name: gl1
38
36
  restart: unless-stopped
39
37
  networks:
40
38
  - tessellation-network
File without changes
@@ -4,15 +4,4 @@ SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
4
4
  # --- build image ---
5
5
  DOCKER_IMAGE_VERSION="${DOCKER_IMAGE_VERSION:-test}"
6
6
  echo "Building tessellation image: constellationnetwork/tessellation:$DOCKER_IMAGE_VERSION"
7
-
8
- # if DEBUG is true use --no-cache argument
9
- if [ "$DEBUG" = "true" ]; then
10
- echo "Debug mode is on, building without cache"
11
- docker build --no-cache -t "constellationnetwork/tessellation:$DOCKER_IMAGE_VERSION" -f "$SCRIPT_DIR/../Dockerfile" .
12
- exit $?
13
- fi
14
- else
15
- docker build -t "constellationnetwork/tessellation:$DOCKER_IMAGE_VERSION" -f "$SCRIPT_DIR/../Dockerfile" .
16
- fi
17
-
18
- # docker build --no-cache -t "constellationnetwork/tessellation:test" -f Dockerfile .
7
+ docker build -t "constellationnetwork/tessellation:$DOCKER_IMAGE_VERSION" -f "$SCRIPT_DIR/../Dockerfile" .
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo "Executing \"cpilot restart --autostart\" at $(date "+%b %d %H:%M:%S")" >> ~/.node-pilot/logs/service.log
@@ -6,7 +6,7 @@
6
6
  <string>io.constellationnetwork.nodepilot.Updater</string>
7
7
  <key>ProgramArguments</key>
8
8
  <array>
9
- <string>/Users/ffox/.node-pilot/scripts/updater.sh</string>
9
+ <string>~/.node-pilot/scripts/updater.sh</string>
10
10
  </array>
11
11
  <key>StartInterval</key>
12
12
  <integer>300</integer>
@@ -4,11 +4,9 @@ After=multi-user.target
4
4
 
5
5
  [Service]
6
6
  Type=simple
7
- User=ubuntu
8
- ExecStart=/home/ubuntu/.node-pilot/scripts/autoheal.sh
7
+ ExecStart=%h/.node-pilot/scripts/autoheal.sh
9
8
  Restart=always
10
9
  RestartSec=15s
11
- ExecStop=/bin/true
12
10
 
13
11
  [Install]
14
12
  WantedBy=multi-user.target
@@ -0,0 +1,11 @@
1
+ [Unit]
2
+ Description=Constellation Network node auto_restart service
3
+ After=multi-user.target
4
+
5
+ [Service]
6
+ Type=Simple
7
+ ExecStartPre=%h/.node-pilot/scripts/restart_logger.sh
8
+ ExecStart=cpilot restart --autostart
9
+
10
+ [Install]
11
+ WantedBy=multi-user.target
@@ -0,0 +1,13 @@
1
+ [Unit]
2
+ Description=Constellation Node Pilot Updater Service
3
+ After=multi-user.target
4
+
5
+ [Service]
6
+ Type=simple
7
+ ExecStartPre=%h/.node-pilot/scripts/update_logger.sh
8
+ ExecStart=cpilot restart --update
9
+ Restart=always
10
+ RestartSec=5m
11
+
12
+ [Install]
13
+ WantedBy=multi-user.target
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo "Executing \"cpilot restart --update\" at $(date "+%b %d %H:%M:%S")" >> ~/.node-pilot/logs/service.log
@@ -1,15 +0,0 @@
1
- [Unit]
2
- Description=Constellation Node Pilot Updater Service
3
- After=multi-user.target
4
-
5
- [Service]
6
- Type=simple
7
- User=ubuntu
8
- ExecStart=/home/ubuntu/.node-pilot/scripts/updater.sh
9
- Environment="PROJECT=hypergraph"
10
- Restart=always
11
- RestartSec=1m
12
- ExecStop=/bin/true
13
-
14
- [Install]
15
- WantedBy=multi-user.target
@@ -1,13 +0,0 @@
1
- #PROJECT="hypergraph"
2
- #: "${PROJECT:=''}"
3
- #if [ -z "$PROJECT" ]; then
4
- # echo "Error: PROJECT environment variable is not set."
5
- # exit 1
6
- #fi
7
- mkdir -p ~/.node-pilot/logs
8
- echo "Check for network update for '$PROJECT' at $(date "+%b %d %H:%M:%S")" >> ~/.node-pilot/logs/updater.log
9
- ~/.node-pilot/$PROJECT/scripts/check-version.sh >> ~/.node-pilot/logs/updater.log 2>&1
10
- exit_code=${PIPESTATUS[0]}
11
- if [ $exit_code -ne 0 ]; then
12
- cpilot restart --project $PROJECT >> ~/.node-pilot/logs/updater.log 2>&1
13
- fi