@constellation-network/node-pilot 0.24.0-devnet.1 → 0.24.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.24.0-devnet.1 darwin-arm64 node-v22.15.0
24
+ @constellation-network/node-pilot/0.24.0-testnet darwin-arm64 node-v22.15.0
25
25
  $ cpilot --help [COMMAND]
26
26
  USAGE
27
27
  $ cpilot COMMAND
@@ -72,7 +72,7 @@ EXAMPLES
72
72
  $ cpilot clean
73
73
  ```
74
74
 
75
- _See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/clean.ts)_
75
+ _See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-testnet/src/commands/clean.ts)_
76
76
 
77
77
  ## `cpilot config`
78
78
 
@@ -89,7 +89,7 @@ EXAMPLES
89
89
  $ cpilot config
90
90
  ```
91
91
 
92
- _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/config.ts)_
92
+ _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-testnet/src/commands/config.ts)_
93
93
 
94
94
  ## `cpilot config get [NAME]`
95
95
 
@@ -113,7 +113,7 @@ EXAMPLES
113
113
  $ cpilot config get gl0:CL_PUBLIC_HTTP_PORT
114
114
  ```
115
115
 
116
- _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/config/get.ts)_
116
+ _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-testnet/src/commands/config/get.ts)_
117
117
 
118
118
  ## `cpilot config set NAME VALUE`
119
119
 
@@ -136,7 +136,7 @@ EXAMPLES
136
136
  $ cpilot config set gl0:CL_PUBLIC_HTTP_PORT 9000
137
137
  ```
138
138
 
139
- _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/config/set.ts)_
139
+ _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-testnet/src/commands/config/set.ts)_
140
140
 
141
141
  ## `cpilot help [COMMAND]`
142
142
 
@@ -173,7 +173,7 @@ EXAMPLES
173
173
  $ cpilot info
174
174
  ```
175
175
 
176
- _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/info.ts)_
176
+ _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-testnet/src/commands/info.ts)_
177
177
 
178
178
  ## `cpilot logs LAYER`
179
179
 
@@ -199,7 +199,7 @@ EXAMPLES
199
199
  $ cpilot logs
200
200
  ```
201
201
 
202
- _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/logs.ts)_
202
+ _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-testnet/src/commands/logs.ts)_
203
203
 
204
204
  ## `cpilot restart [LAYER]`
205
205
 
@@ -223,7 +223,7 @@ EXAMPLES
223
223
  $ cpilot restart
224
224
  ```
225
225
 
226
- _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/restart.ts)_
226
+ _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-testnet/src/commands/restart.ts)_
227
227
 
228
228
  ## `cpilot shutdown`
229
229
 
@@ -240,7 +240,7 @@ EXAMPLES
240
240
  $ cpilot shutdown
241
241
  ```
242
242
 
243
- _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/shutdown.ts)_
243
+ _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-testnet/src/commands/shutdown.ts)_
244
244
 
245
245
  ## `cpilot status`
246
246
 
@@ -254,7 +254,7 @@ DESCRIPTION
254
254
  Display node status and configuration settings
255
255
  ```
256
256
 
257
- _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/status.ts)_
257
+ _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-testnet/src/commands/status.ts)_
258
258
 
259
259
  ## `cpilot uninstall`
260
260
 
@@ -271,5 +271,5 @@ EXAMPLES
271
271
  $ cpilot uninstall
272
272
  ```
273
273
 
274
- _See code: [src/commands/uninstall.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/uninstall.ts)_
274
+ _See code: [src/commands/uninstall.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-testnet/src/commands/uninstall.ts)_
275
275
  <!-- commandsstop -->
@@ -36,13 +36,11 @@ export const delegatedStakingService = {
36
36
  clm.postStep(`Delegated Staking Page: https://${type}.dagexplorer.io/staking`);
37
37
  },
38
38
  async generateNodeParamPayload(rewardFraction, name, description, lastRef) {
39
- name = name.replaceAll(/['"]/g, match => `\\${match}`);
40
- description = description.replaceAll(/['"]/g, match => `\\${match}`);
41
39
  rewardFraction = Math.max(.05, Math.min(.1, rewardFraction));
42
40
  const env = configStore.getEnvInfo();
43
41
  const { projectDir } = configStore.getProjectInfo();
44
42
  fs.writeFileSync(path.join(projectDir, 'parent.json'), JSON.stringify(lastRef));
45
- const command = `java -jar dist/wallet.jar create-node-params --reward-fraction ${rewardFraction} --name $'${name}' --description $'${description}' -p 'parent.json'`;
43
+ const command = `java -jar dist/wallet.jar create-node-params --reward-fraction ${rewardFraction} --name ${shQuote(name)} --description ${shQuote(description)} -p 'parent.json'`;
46
44
  await shellService.runProjectCommand(command, env);
47
45
  return fs.readFileSync(path.join(projectDir, 'event'), 'utf8');
48
46
  },
@@ -63,3 +61,15 @@ export const delegatedStakingService = {
63
61
  });
64
62
  }
65
63
  };
64
+ // Wrap a string as a single-quoted POSIX shell argument.
65
+ // POSIX single quotes have NO escape mechanism — backslashes inside
66
+ // '...' are literal — so 'It\'s great' does NOT work (the second '
67
+ // closes the string, leaving the rest unquoted/unclosed).
68
+ // To embed a ', splice three adjacent tokens:
69
+ // 'It' + \' + 's great'
70
+ // (close) (escaped ' outside any quotes) (reopen)
71
+ // The shell concatenates adjacent tokens into one argument:
72
+ // It's great → 'It'\''s great'
73
+ function shQuote(s) {
74
+ return `'${s.replaceAll("'", String.raw `'\''`)}'`;
75
+ }
@@ -1,21 +1,35 @@
1
1
  import semver from "semver";
2
2
  import { clm } from "../clm.js";
3
3
  import { configStore } from "../config-store.js";
4
+ import { pilotManager } from "../helpers/pilot-manager.js";
4
5
  import { projectHelper } from "../helpers/project-helper.js";
5
6
  import { dockerService } from "./docker-service.js";
6
7
  import { nodeService } from "./node-service.js";
7
8
  import { shellService } from "./shell-service.js";
9
+ import { systemdService } from "./systemd-service.js";
8
10
  const migrations = {
9
11
  '0.24.0-0': {
10
12
  description: 'host Java 21; container Java is network-aware (11 for mainnet, 21 elsewhere)',
11
13
  requiresNodeRestart: true,
12
14
  async run() {
15
+ // Backfill projectInfo.type for users coming from old code that only
16
+ // set `name`. Safe across networks: testnet/intnet installs already
17
+ // populate `type`, so the guard short-circuits.
18
+ const projectInfo = configStore.getProjectInfo();
19
+ if (!projectInfo.type && projectInfo.name) {
20
+ configStore.setProjectInfo({ type: projectInfo.name });
21
+ }
13
22
  configStore.setProjectFlag('javaMemoryChecked', false);
23
+ // Tear down any stale systemd units before refreshing files; we
24
+ // reinstall fresh ones at the end of the body so the safety net
25
+ // (auto-update, restart-unhealthy) is in place after restart.
26
+ await systemdService.uninstall();
14
27
  projectHelper.upgradeHypergraph();
15
28
  const { type: network } = configStore.getNetworkInfo();
16
29
  const JAVA_VERSION = network === 'mainnet' ? '11' : '21';
17
30
  await shellService.runProjectCommand('bash scripts/install-dependencies.sh', { JAVA_VERSION });
18
31
  await refreshJavaHome();
32
+ await systemdService.install();
19
33
  }
20
34
  }
21
35
  };
@@ -54,20 +68,28 @@ async function runMigration(key, migration) {
54
68
  await migration.run();
55
69
  return;
56
70
  }
57
- const wasRunning = await dockerService.isRunning();
58
- if (wasRunning) {
59
- clm.preStep('Shutting down node to apply migration changes...');
60
- const { layersToRun } = configStore.getProjectInfo();
61
- await nodeService.leaveClusterAllLayers();
62
- await nodeService.pollForLayersState(layersToRun, 'Offline');
63
- await dockerService.dockerDown();
71
+ // Claim the restart lock for the whole lifecycle so any cpilot restart
72
+ // commands kicked off by systemd (auto-update, autostart) bail out cleanly.
73
+ pilotManager.setIsRestarting(Date.now());
74
+ try {
75
+ const wasRunning = await dockerService.isRunning();
76
+ if (wasRunning) {
77
+ clm.preStep('Shutting down node to apply migration changes...');
78
+ const { layersToRun } = configStore.getProjectInfo();
79
+ await nodeService.leaveClusterAllLayers();
80
+ await nodeService.pollForLayersState(layersToRun, 'Offline');
81
+ await dockerService.dockerDown();
82
+ }
83
+ await migration.run();
84
+ if (wasRunning) {
85
+ clm.preStep('Rebuilding container with refreshed Dockerfile...');
86
+ await dockerService.dockerBuild();
87
+ clm.preStep('Restarting node...');
88
+ await dockerService.dockerRestartAll();
89
+ }
64
90
  }
65
- await migration.run();
66
- if (wasRunning) {
67
- clm.preStep('Rebuilding container with refreshed Dockerfile...');
68
- await dockerService.dockerBuild();
69
- clm.preStep('Restarting node...');
70
- await dockerService.dockerRestartAll();
91
+ finally {
92
+ pilotManager.setIsRestarting(0);
71
93
  }
72
94
  }
73
95
  async function refreshJavaHome() {
@@ -449,5 +449,5 @@
449
449
  ]
450
450
  }
451
451
  },
452
- "version": "0.24.0-devnet.1"
452
+ "version": "0.24.0-testnet"
453
453
  }
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.24.0-devnet.1",
4
+ "version": "0.24.0-testnet",
5
5
  "author": "Frank Fox",
6
6
  "bin": {
7
7
  "cpilot": "bin/run.js"