@constellation-network/node-pilot 0.0.9 → 0.0.11
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 +15 -11
- package/dist/base-command.js +1 -1
- package/dist/checks/check-initial-setup.js +2 -0
- package/dist/checks/check-project.d.ts +1 -0
- package/dist/checks/check-project.js +11 -5
- package/dist/commands/restart.d.ts +5 -0
- package/dist/commands/restart.js +43 -7
- package/dist/commands/test.js +1 -2
- package/dist/config-store.d.ts +4 -1
- package/dist/config-store.js +35 -17
- package/dist/services/docker-service.js +3 -4
- package/dist/services/notify-service.d.ts +1 -0
- package/dist/services/notify-service.js +1 -0
- package/dist/services/systemd-service.d.ts +3 -0
- package/dist/services/systemd-service.js +45 -0
- package/oclif.manifest.json +14 -2
- package/package.json +1 -1
- package/projects/custom/pilot.json +9 -0
- package/projects/hypergraph/Dockerfile +1 -1
- package/projects/hypergraph/docker-compose.yml +6 -7
- package/projects/hypergraph/scripts/check-version.sh +0 -0
- package/projects/hypergraph/scripts/docker-build.sh +1 -12
- package/scripts/restart_logger.sh +3 -0
- package/scripts/services/io.constellationnetwork.nodepilot.Updater.plist +1 -1
- package/scripts/services/node-pilot-autoheal.service +1 -3
- package/scripts/services/node-pilot-restarter.service +12 -0
- package/scripts/services/node-pilot-updater.service +14 -0
- package/scripts/update_logger.sh +3 -0
- package/scripts/services/node-pilot-updater-hypergraph.service +0 -15
- package/scripts/updater.sh +0 -13
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.11 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.11/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.11/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.11/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.11/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.11/src/commands/logs.ts)_
|
174
174
|
|
175
175
|
## `cpilot restart [LAYER]`
|
176
176
|
|
@@ -178,10 +178,14 @@ 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 hypergraph] [--autostart] [--update]
|
182
182
|
|
183
183
|
ARGUMENTS
|
184
|
-
LAYER network layer to
|
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
|
@@ -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.
|
201
|
+
_See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.11/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.
|
218
|
+
_See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.11/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.
|
232
|
+
_See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.11/src/commands/status.ts)_
|
229
233
|
<!-- commandsstop -->
|
package/dist/base-command.js
CHANGED
@@ -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
|
};
|
@@ -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
|
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 ===
|
88
|
-
clm.postStep(`Network files are already installed for ${nInfo.type} 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}`,
|
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
|
}
|
package/dist/commands/restart.js
CHANGED
@@ -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
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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...');
|
package/dist/commands/test.js
CHANGED
@@ -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`);
|
package/dist/config-store.d.ts
CHANGED
@@ -4,7 +4,7 @@ declare class ConfigStore {
|
|
4
4
|
private projectStore;
|
5
5
|
constructor();
|
6
6
|
applyNewProjectStore(name: string): Promise<void>;
|
7
|
-
|
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;
|
package/dist/config-store.js
CHANGED
@@ -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
|
-
|
52
|
-
const {
|
53
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
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.
|
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,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
|
+
};
|
package/oclif.manifest.json
CHANGED
@@ -95,7 +95,7 @@
|
|
95
95
|
"aliases": [],
|
96
96
|
"args": {
|
97
97
|
"layer": {
|
98
|
-
"description": "network layer to
|
98
|
+
"description": "network layer to restart. e.g. gl0",
|
99
99
|
"name": "layer"
|
100
100
|
}
|
101
101
|
},
|
@@ -115,6 +115,18 @@
|
|
115
115
|
"hypergraph"
|
116
116
|
],
|
117
117
|
"type": "option"
|
118
|
+
},
|
119
|
+
"autostart": {
|
120
|
+
"description": "restart each running project if it has been stopped",
|
121
|
+
"name": "autostart",
|
122
|
+
"allowNo": false,
|
123
|
+
"type": "boolean"
|
124
|
+
},
|
125
|
+
"update": {
|
126
|
+
"description": "update each project if a new version is available",
|
127
|
+
"name": "update",
|
128
|
+
"allowNo": false,
|
129
|
+
"type": "boolean"
|
118
130
|
}
|
119
131
|
},
|
120
132
|
"hasDynamicHelp": false,
|
@@ -264,5 +276,5 @@
|
|
264
276
|
]
|
265
277
|
}
|
266
278
|
},
|
267
|
-
"version": "0.0.
|
279
|
+
"version": "0.0.11"
|
268
280
|
}
|
package/package.json
CHANGED
@@ -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
|
+
|
@@ -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"
|
42
|
+
RUN npm install -g "@constellation-network/node-pilot-health-check@latest"
|
43
43
|
|
44
44
|
# Add entrypoint
|
45
45
|
COPY ./entrypoint.sh /app/entrypoint.sh
|
@@ -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
|
@@ -19,22 +18,22 @@ services:
|
|
19
18
|
- "9000:9000" # Public HTTP
|
20
19
|
- "9001:9001" # P2P HTTP
|
21
20
|
volumes:
|
21
|
+
- ./gl0/data:/app/data
|
22
|
+
- ./gl0/logs:/app/logs
|
22
23
|
- ./key.p12:/app/key.p12:ro
|
23
24
|
- ./seedlist:/app/seedlist:ro
|
24
|
-
- ./app-data/gl0-logs:/app/logs
|
25
|
-
- ./app-data/gl0-data:/app/data
|
26
25
|
healthcheck:
|
27
26
|
test: ["CMD", "cpilotHC"]
|
27
|
+
# test: ["CMD", "/health-check/bin/run.sh"]
|
28
28
|
interval: 15s
|
29
29
|
retries: 1
|
30
30
|
timeout: 15s
|
31
|
-
start_period:
|
31
|
+
start_period: 60s
|
32
32
|
profiles: ["gl0"]
|
33
33
|
labels:
|
34
34
|
autoheal: "true"
|
35
35
|
gl1:
|
36
36
|
image: constellationnetwork/tessellation${CL_DOCKER_CORE_REPO:-}:${DOCKER_IMAGE_VERSION:-latest}
|
37
|
-
container_name: gl1
|
38
37
|
restart: unless-stopped
|
39
38
|
networks:
|
40
39
|
- tessellation-network
|
@@ -44,9 +43,9 @@ services:
|
|
44
43
|
- "9010:9010" # Public HTTP
|
45
44
|
- "9011:9011" # P2P HTTP
|
46
45
|
volumes:
|
46
|
+
- ./gl1/data:/app/data
|
47
|
+
- ./gl1/logs:/app/logs
|
47
48
|
- ./key.p12:/app/key.p12:ro
|
48
|
-
- ./app-data/gl1-logs:/app/logs
|
49
|
-
- ./app-data/gl1-data:/app/data
|
50
49
|
# healthcheck:
|
51
50
|
# test: ["CMD", "/app/internal-health-check.sh"]
|
52
51
|
# interval: 3s
|
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" .
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<string>io.constellationnetwork.nodepilot.Updater</string>
|
7
7
|
<key>ProgramArguments</key>
|
8
8
|
<array>
|
9
|
-
<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
|
-
|
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,12 @@
|
|
1
|
+
[Unit]
|
2
|
+
Description=Constellation Network node auto_restart service
|
3
|
+
After=multi-user.target
|
4
|
+
|
5
|
+
[Service]
|
6
|
+
Type=simple
|
7
|
+
User=ubuntu
|
8
|
+
ExecStartPre=%h/.node-pilot/scripts/restart_logger.sh
|
9
|
+
ExecStart=cpilot restart --autostart
|
10
|
+
|
11
|
+
[Install]
|
12
|
+
WantedBy=multi-user.target
|
@@ -0,0 +1,14 @@
|
|
1
|
+
[Unit]
|
2
|
+
Description=Constellation Node Pilot Updater Service
|
3
|
+
After=multi-user.target
|
4
|
+
|
5
|
+
[Service]
|
6
|
+
Type=simple
|
7
|
+
User=ubuntu
|
8
|
+
ExecStartPre=%h/.node-pilot/scripts/update_logger.sh
|
9
|
+
ExecStart=cpilot restart --update
|
10
|
+
Restart=always
|
11
|
+
RestartSec=5m
|
12
|
+
|
13
|
+
[Install]
|
14
|
+
WantedBy=multi-user.target
|
@@ -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
|
package/scripts/updater.sh
DELETED
@@ -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
|