Skip to content

Commit 5a193d4

Browse files
authored
fix(dashmate): restart for rs-dapi and envoy (#2821)
1 parent 29f7492 commit 5a193d4

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

packages/dashmate/src/listr/tasks/startNodeTaskFactory.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const DAPI_PROFILE_SERVICES = {
1919
* @param {getConnectionHost} getConnectionHost
2020
* @param {ensureFileMountExists} ensureFileMountExists
2121
* @param {HomeDir} homeDir
22+
* @param {getConfigProfiles} getConfigProfiles
2223
* @return {startNodeTask}
2324
*/
2425
export default function startNodeTaskFactory(
@@ -30,7 +31,19 @@ export default function startNodeTaskFactory(
3031
getConnectionHost,
3132
ensureFileMountExists,
3233
homeDir,
34+
getConfigProfiles,
3335
) {
36+
function getPlatformProfiles(config) {
37+
const platformProfiles = getConfigProfiles(config)
38+
.filter((profile) => profile.startsWith('platform'));
39+
40+
if (platformProfiles.length === 0) {
41+
platformProfiles.push('platform');
42+
}
43+
44+
return Array.from(new Set(platformProfiles));
45+
}
46+
3447
/**
3548
* @typedef {startNodeTask}
3649
* @param {Config} config
@@ -89,10 +102,7 @@ export default function startNodeTaskFactory(
89102
title: 'Check node is not started',
90103
enabled: (ctx) => !ctx.isForce,
91104
task: async (ctx) => {
92-
const profiles = [];
93-
if (ctx.platformOnly) {
94-
profiles.push('platform');
95-
}
105+
const profiles = ctx.platformOnly ? getPlatformProfiles(config) : [];
96106

97107
if (await dockerCompose.isNodeRunning(config, { profiles })) {
98108
throw new Error('Running services detected. Please ensure all services are stopped for this config before starting');
@@ -147,10 +157,7 @@ export default function startNodeTaskFactory(
147157
config.get('core.masternode.operator.privateKey', true);
148158
}
149159

150-
const profiles = [];
151-
if (ctx.platformOnly) {
152-
profiles.push('platform');
153-
}
160+
const profiles = ctx.platformOnly ? getPlatformProfiles(config) : [];
154161

155162
await dockerCompose.up(config, { profiles });
156163
},

packages/dashmate/src/listr/tasks/stopNodeTaskFactory.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,26 @@ import waitForDKGWindowPass from '../../core/quorum/waitForDKGWindowPass.js';
77
* @param {DockerCompose} dockerCompose
88
* @param {createRpcClient} createRpcClient
99
* @param {getConnectionHost} getConnectionHost
10+
* @param {getConfigProfiles} getConfigProfiles
1011
* @return {stopNodeTask}
1112
*/
1213
export default function stopNodeTaskFactory(
1314
dockerCompose,
1415
createRpcClient,
1516
getConnectionHost,
17+
getConfigProfiles,
1618
) {
19+
function getPlatformProfiles(config) {
20+
const platformProfiles = getConfigProfiles(config)
21+
.filter((profile) => profile.startsWith('platform'));
22+
23+
if (platformProfiles.length === 0) {
24+
platformProfiles.push('platform');
25+
}
26+
27+
return Array.from(new Set(platformProfiles));
28+
}
29+
1730
/**
1831
* Stop node
1932
* @typedef stopNodeTask
@@ -27,10 +40,7 @@ export default function stopNodeTaskFactory(
2740
title: 'Check node is running',
2841
skip: (ctx) => ctx.isForce,
2942
task: async (ctx) => {
30-
const profiles = [];
31-
if (ctx.platformOnly) {
32-
profiles.push('platform');
33-
}
43+
const profiles = ctx.platformOnly ? getPlatformProfiles(config) : [];
3444

3545
if (!await dockerCompose.isNodeRunning(config, { profiles })) {
3646
throw new Error('Node is not running');
@@ -70,10 +80,8 @@ export default function stopNodeTaskFactory(
7080
{
7181
title: `Stopping ${config.getName()} node`,
7282
task: async (ctx) => {
73-
const profiles = [];
74-
if (ctx.platformOnly) {
75-
profiles.push('platform');
76-
}
83+
const profiles = ctx.platformOnly ? getPlatformProfiles(config) : [];
84+
7785
await dockerCompose.stop(config, { profiles });
7886
},
7987
},

0 commit comments

Comments
 (0)