@constellation-network/node-pilot 0.0.13 → 0.0.14

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.13 darwin-arm64 node-v22.15.0
24
+ @constellation-network/node-pilot/0.0.14 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.13/src/commands/config.ts)_
65
+ _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.14/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.13/src/commands/config/get.ts)_
89
+ _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.14/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.13/src/commands/config/set.ts)_
112
+ _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.14/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.13/src/commands/info.ts)_
149
+ _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.14/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.13/src/commands/logs.ts)_
173
+ _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.14/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.13/src/commands/restart.ts)_
201
+ _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.14/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.13/src/commands/shutdown.ts)_
218
+ _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.14/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.13/src/commands/status.ts)_
232
+ _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.14/src/commands/status.ts)_
233
233
  <!-- commandsstop -->
@@ -75,16 +75,24 @@ export default class Restart extends BaseCommand {
75
75
  // const pAll = layersToRun.map(l => nodeService.getNodeInfo(l));
76
76
  // const info = await Promise.all(pAll);
77
77
  // const isRunning = info.some(n => n.state !== 'Unavailable');
78
- if (await dockerService.isRunning()) {
79
- await nodeService.leaveClusterAllLayers();
80
- const { layersToRun } = configStore.getProjectInfo();
81
- await nodeService.pollForLayersState(layersToRun, 'Offline');
82
- clm.preStep('Stopping the node...');
83
- await dockerService.dockerDown();
78
+ if (configStore.isRestarting())
79
+ return;
80
+ configStore.setIsRestarting(true);
81
+ try {
82
+ if (await dockerService.isRunning()) {
83
+ await nodeService.leaveClusterAllLayers();
84
+ const { layersToRun } = configStore.getProjectInfo();
85
+ await nodeService.pollForLayersState(layersToRun, 'Offline');
86
+ clm.preStep('Stopping the node...');
87
+ await dockerService.dockerDown();
88
+ }
89
+ clm.preStep('Checking for a new version...');
90
+ await checkProject.runUpgrade();
91
+ clm.preStep('Starting the node...');
92
+ await dockerService.dockerUp();
93
+ }
94
+ finally {
95
+ configStore.setIsRestarting(false);
84
96
  }
85
- clm.preStep('Checking for a new version...');
86
- await checkProject.runUpgrade();
87
- clm.preStep('Starting the node...');
88
- await dockerService.dockerUp();
89
97
  }
90
98
  }
@@ -18,6 +18,7 @@ declare class ConfigStore {
18
18
  getSystemInfo(): SystemInfo;
19
19
  hasProjectFlag(name: string): any;
20
20
  hasProjects(): boolean;
21
+ isRestarting(): boolean;
21
22
  setActiveProject(name: string): void;
22
23
  setClusterStats(info: Partial<ClusterStats>): void;
23
24
  setDockerEnvInfo(info: Partial<{
@@ -27,6 +28,7 @@ declare class ConfigStore {
27
28
  setEnvInfo(info: Partial<EnvInfo>): void;
28
29
  setEnvLayerInfo(network: NetworkType, layer: TessellationLayer, info: Partial<EnvLayerInfo>): void;
29
30
  setEnvNetworkInfo(network: NetworkType, info: Partial<EnvNetworkInfo>): void;
31
+ setIsRestarting(val: boolean): void;
30
32
  setNetworkInfo(info: Partial<NetworkInfo>): void;
31
33
  setProjectFlag(name: string, value: boolean): any;
32
34
  setProjectInfo(info: Partial<ProjectInfo>): void;
@@ -20,7 +20,7 @@ class ConfigStore {
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: [], running: [] });
23
+ this.pilotStore.setItem('pilot', { appDir, project: 'undefined', projects: [], restarting: false, 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'));
@@ -104,6 +104,10 @@ class ConfigStore {
104
104
  const { projects } = this.pilotStore.getItem('pilot');
105
105
  return projects.length > 0;
106
106
  }
107
+ isRestarting() {
108
+ const { restarting } = this.pilotStore.getItem('pilot');
109
+ return restarting;
110
+ }
107
111
  setActiveProject(name) {
108
112
  const { appDir, project, projects } = this.pilotStore.getItem('pilot');
109
113
  if (projects && projects.includes(name)) {
@@ -142,6 +146,9 @@ class ConfigStore {
142
146
  networks = {};
143
147
  this.projectStore.setItem('network-env', { ...networks, [network]: { ...networks[network], ...info } });
144
148
  }
149
+ setIsRestarting(val) {
150
+ this.setPilotInfo({ restarting: val });
151
+ }
145
152
  setNetworkInfo(info) {
146
153
  const oldInfo = this.projectStore.getItem('network');
147
154
  this.projectStore.setItem('network', { ...oldInfo, ...info });
@@ -276,5 +276,5 @@
276
276
  ]
277
277
  }
278
278
  },
279
- "version": "0.0.13"
279
+ "version": "0.0.14"
280
280
  }
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.13",
4
+ "version": "0.0.14",
5
5
  "author": "Frank Fox",
6
6
  "bin": {
7
7
  "cpilot": "bin/run.js"
@@ -17,10 +17,12 @@ After=docker.service
17
17
  Wants=docker.service
18
18
 
19
19
  [Service]
20
- ExecStartPre=/bin/sleep 300
21
20
  ExecStart=$WORKING_DIR/restart-unhealthy.sh
22
21
  Restart=always
23
22
  RestartSec=60s
23
+
24
+ [Install]
25
+ WantedBy=docker.service
24
26
  EOF
25
27
 
26
28
  cat << EOF > $WORKING_DIR/restart-unhealthy.sh
@@ -48,7 +50,6 @@ Description=Constellation Node Pilot Updater Service
48
50
  After=default.target
49
51
 
50
52
  [Service]
51
- ExecStartPre=/bin/sleep 300
52
53
  ExecStart=$CPILOT restart --update
53
54
  Restart=always
54
55
  RestartSec=5m