@constellation-network/node-pilot 0.0.11 → 0.0.13
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 +26 -17
- package/dist/config-store.d.ts +1 -0
- package/dist/helpers/project-helper.js +2 -2
- package/dist/helpers/service-log.d.ts +3 -0
- package/dist/helpers/service-log.js +10 -0
- package/dist/services/archiver-service.js +3 -3
- package/dist/services/fastforward-service.js +15 -3
- package/dist/services/systemd-service.js +6 -29
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
- package/scripts/install_services.sh +70 -0
- package/scripts/autoheal.sh +0 -8
- package/scripts/restart_logger.sh +0 -3
- package/scripts/services/io.constellationnetwork.nodepilot.Updater.plist +0 -16
- package/scripts/services/node-pilot-autoheal.service +0 -12
- package/scripts/services/node-pilot-restarter.service +0 -12
- package/scripts/services/node-pilot-updater.service +0 -14
- package/scripts/update_logger.sh +0 -3
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.13 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.13/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.13/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.13/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.13/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.13/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.13/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.13/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.13/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
@@ -4,6 +4,7 @@ import { checkProject } from "../checks/check-project.js";
|
|
4
4
|
import { clm } from "../clm.js";
|
5
5
|
import { configStore } from "../config-store.js";
|
6
6
|
import { configHelper } from "../helpers/config-helper.js";
|
7
|
+
import { serviceLog } from "../helpers/service-log.js";
|
7
8
|
import { dockerService } from "../services/docker-service.js";
|
8
9
|
import { nodeService } from "../services/node-service.js";
|
9
10
|
export default class Restart extends BaseCommand {
|
@@ -22,27 +23,16 @@ export default class Restart extends BaseCommand {
|
|
22
23
|
const { args, flags } = await this.parse(Restart);
|
23
24
|
this.checkProject(flags);
|
24
25
|
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
26
|
if (flags.update) {
|
27
|
+
serviceLog.log('Executing "cpilot restart --update" at ' + new Date().toLocaleString('en-US', { timeZone: 'America/Los_Angeles' }));
|
41
28
|
const project = configStore.getActiveProject();
|
42
|
-
|
29
|
+
const activeProjects = configStore.getRunningProjects();
|
30
|
+
serviceLog.log(` Active projects: ${activeProjects.join(', ')}...`);
|
31
|
+
for (const project of activeProjects) {
|
43
32
|
configStore.setActiveProject(project);
|
44
33
|
// eslint-disable-next-line no-await-in-loop
|
45
34
|
if (await checkProject.hasVersionChanged()) {
|
35
|
+
serviceLog.log(' ' + project + ' version has changed. Restarting...');
|
46
36
|
// eslint-disable-next-line no-await-in-loop
|
47
37
|
await this.restart();
|
48
38
|
}
|
@@ -51,8 +41,12 @@ export default class Restart extends BaseCommand {
|
|
51
41
|
return;
|
52
42
|
}
|
53
43
|
if (flags.autostart) {
|
44
|
+
serviceLog.log('Executing "cpilot restart --autostart" at ' + new Date().toLocaleString('en-US', { timeZone: 'America/Los_Angeles' }));
|
54
45
|
const project = configStore.getActiveProject();
|
55
|
-
|
46
|
+
const activeProjects = configStore.getRunningProjects();
|
47
|
+
serviceLog.log(` Active projects: ${activeProjects.join(', ')}...`);
|
48
|
+
for (const project of activeProjects) {
|
49
|
+
serviceLog.log(' ' + project + ' is restarting...');
|
56
50
|
configStore.setActiveProject(project);
|
57
51
|
// eslint-disable-next-line no-await-in-loop
|
58
52
|
await this.restart();
|
@@ -60,6 +54,21 @@ export default class Restart extends BaseCommand {
|
|
60
54
|
configStore.setActiveProject(project);
|
61
55
|
return;
|
62
56
|
}
|
57
|
+
if (!await dockerService.isRunning()) {
|
58
|
+
this.error('The validator node is not running.');
|
59
|
+
}
|
60
|
+
if (args && args.layer) {
|
61
|
+
const { layersToRun } = configStore.getProjectInfo();
|
62
|
+
const layer = args.layer;
|
63
|
+
if (!layersToRun.includes(layer)) {
|
64
|
+
this.error(`Invalid layer: ${layer}. Available layers: ${layersToRun.join(',')}`);
|
65
|
+
}
|
66
|
+
await nodeService.leaveCluster(layer);
|
67
|
+
await nodeService.pollForLayersState([layer], 'Offline');
|
68
|
+
clm.preStep(`Restarting ${layer.toUpperCase()}...`);
|
69
|
+
await dockerService.dockerRestart(layer);
|
70
|
+
return;
|
71
|
+
}
|
63
72
|
await this.restart();
|
64
73
|
}
|
65
74
|
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'));
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import fs from "node:fs";
|
2
|
+
import path from "node:path";
|
3
|
+
import { configStore } from "../config-store.js";
|
4
|
+
export const serviceLog = {
|
5
|
+
log(s) {
|
6
|
+
const appDir = configStore.getAppDir();
|
7
|
+
const logFile = path.join(appDir, 'logs', 'service.log');
|
8
|
+
fs.appendFileSync(logFile, s + '\n');
|
9
|
+
},
|
10
|
+
};
|
@@ -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);
|
@@ -4,7 +4,6 @@ import { fileURLToPath } from "node:url";
|
|
4
4
|
import { clm } from "../clm.js";
|
5
5
|
import { configStore } from "../config-store.js";
|
6
6
|
import { shellService } from "./shell-service.js";
|
7
|
-
const INSTALL_PATH = '/etc/systemd/system/';
|
8
7
|
export const systemdService = {
|
9
8
|
async install() {
|
10
9
|
const { platform } = configStore.getSystemInfo();
|
@@ -12,34 +11,12 @@ export const systemdService = {
|
|
12
11
|
clm.warn('Node Pilot services can only be installed on Linux systems. Skipping systemd service installation.\n');
|
13
12
|
return;
|
14
13
|
}
|
15
|
-
const
|
16
|
-
if (!fs.existsSync(
|
17
|
-
clm.error(`Node Pilot services
|
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.');
|
14
|
+
const installServicesScript = path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../scripts/install_services.sh`);
|
15
|
+
if (!fs.existsSync(installServicesScript)) {
|
16
|
+
clm.error(`Node Pilot install system services script not found: ${installServicesScript}`);
|
43
17
|
}
|
18
|
+
clm.preStep('Installing Node Pilot system services...');
|
19
|
+
await shellService.runCommand(installServicesScript);
|
20
|
+
clm.postStep('\nNode Pilot system service started successfully.');
|
44
21
|
}
|
45
22
|
};
|
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.13",
|
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",
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
CPILOT=$(command -v cpilot)
|
4
|
+
if [ -z "$CPILOT" ]; then
|
5
|
+
echo "cpilot command not found. Please ensure Node Pilot is installed and accessible in your PATH."
|
6
|
+
exit 1
|
7
|
+
fi
|
8
|
+
|
9
|
+
WORKING_DIR=/home/$USER/.config/systemd/user
|
10
|
+
|
11
|
+
mkdir -p $WORKING_DIR
|
12
|
+
|
13
|
+
cat << EOF > $WORKING_DIR/restart-unhealthy.service
|
14
|
+
[Unit]
|
15
|
+
Description=Restart unhealthy docker containers
|
16
|
+
After=docker.service
|
17
|
+
Wants=docker.service
|
18
|
+
|
19
|
+
[Service]
|
20
|
+
ExecStartPre=/bin/sleep 300
|
21
|
+
ExecStart=$WORKING_DIR/restart-unhealthy.sh
|
22
|
+
Restart=always
|
23
|
+
RestartSec=60s
|
24
|
+
EOF
|
25
|
+
|
26
|
+
cat << EOF > $WORKING_DIR/restart-unhealthy.sh
|
27
|
+
#!/usr/bin/env bash
|
28
|
+
docker ps -q -f health=unhealthy | xargs --no-run-if-empty docker restart
|
29
|
+
EOF
|
30
|
+
|
31
|
+
chmod +x $WORKING_DIR/restart-unhealthy.sh
|
32
|
+
|
33
|
+
cat << EOF > $WORKING_DIR/node-pilot-autostart.service
|
34
|
+
[Unit]
|
35
|
+
Description=Constellation Network Node Auto Restart Service
|
36
|
+
After=default.target
|
37
|
+
|
38
|
+
[Service]
|
39
|
+
ExecStart=$CPILOT restart --autostart
|
40
|
+
|
41
|
+
[Install]
|
42
|
+
WantedBy=default.target
|
43
|
+
EOF
|
44
|
+
|
45
|
+
cat << EOF > $WORKING_DIR/node-pilot-update.service
|
46
|
+
[Unit]
|
47
|
+
Description=Constellation Node Pilot Updater Service
|
48
|
+
After=default.target
|
49
|
+
|
50
|
+
[Service]
|
51
|
+
ExecStartPre=/bin/sleep 300
|
52
|
+
ExecStart=$CPILOT restart --update
|
53
|
+
Restart=always
|
54
|
+
RestartSec=5m
|
55
|
+
|
56
|
+
[Install]
|
57
|
+
WantedBy=default.target
|
58
|
+
EOF
|
59
|
+
|
60
|
+
systemctl --user daemon-reload
|
61
|
+
|
62
|
+
systemctl --user enable restart-unhealthy.service
|
63
|
+
systemctl --user enable node-pilot-autostart.service
|
64
|
+
systemctl --user enable node-pilot-update.service
|
65
|
+
|
66
|
+
systemctl --user start restart-unhealthy.service
|
67
|
+
systemctl --user start node-pilot-autostart.service
|
68
|
+
systemctl --user start node-pilot-update.service
|
69
|
+
|
70
|
+
loginctl enable-linger $USER
|
package/scripts/autoheal.sh
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
# This script monitors Docker containers and restarts any that are unhealthy.
|
3
|
-
|
4
|
-
unhealthy_containers=$(docker ps -q --filter health=unhealthy)
|
5
|
-
if [ -n "$unhealthy_containers" ]; then
|
6
|
-
echo "Restarting unhealthy containers: $unhealthy_containers"
|
7
|
-
docker restart $unhealthy_containers
|
8
|
-
fi
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
-
<plist version="1.0">
|
4
|
-
<dict>
|
5
|
-
<key>Label</key>
|
6
|
-
<string>io.constellationnetwork.nodepilot.Updater</string>
|
7
|
-
<key>ProgramArguments</key>
|
8
|
-
<array>
|
9
|
-
<string>~/.node-pilot/scripts/updater.sh</string>
|
10
|
-
</array>
|
11
|
-
<key>StartInterval</key>
|
12
|
-
<integer>300</integer>
|
13
|
-
<key>RunAtLoad</key>
|
14
|
-
<boolean>true</boolean>
|
15
|
-
</dict>
|
16
|
-
</plist>
|
@@ -1,12 +0,0 @@
|
|
1
|
-
[Unit]
|
2
|
-
Description=Constellation node pilot docker container auto heal service
|
3
|
-
After=multi-user.target
|
4
|
-
|
5
|
-
[Service]
|
6
|
-
Type=simple
|
7
|
-
ExecStart=%h/.node-pilot/scripts/autoheal.sh
|
8
|
-
Restart=always
|
9
|
-
RestartSec=15s
|
10
|
-
|
11
|
-
[Install]
|
12
|
-
WantedBy=multi-user.target
|
@@ -1,12 +0,0 @@
|
|
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
|
@@ -1,14 +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
|
-
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
|
package/scripts/update_logger.sh
DELETED