Skip to content

Commit

Permalink
feat: implement node start and stop commands (#520)
Browse files Browse the repository at this point in the history
Signed-off-by: Lenin Mehedy <[email protected]>
  • Loading branch information
leninmehedy authored Nov 10, 2023
1 parent 598eeaf commit 9883fa7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fullstack-network-manager/src/commands/cluster.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class ClusterCommand extends BaseCommand {
desc: 'Setup cluster with shared components',
builder: yargs => {
yargs.option('cluster-name', flags.clusterNameFlag)
yargs.option('namespace', flags.defaultNamespaceFlag)
yargs.option('namespace', flags.namespaceFlag)
yargs.option('prometheus-stack', flags.deployPrometheusStack)
yargs.option('minio', flags.deployMinio)
yargs.option('envoy-gateway', flags.deployEnvoyGateway)
Expand Down
40 changes: 39 additions & 1 deletion fullstack-network-manager/src/commands/node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class NodeCommand extends BaseCommand {
'--no-headers',
`-o custom-columns=":metadata.name"`,
`-n "${namespace}"`
)
)
output.forEach(podName => {
nodeIds.push(Templates.extractNodeIdFromPodName(podName))
podNames.push(podName)
Expand Down Expand Up @@ -110,6 +110,8 @@ export class NodeCommand extends BaseCommand {
for (const podName of podNames) {
await self.plaformInstaller.install(podName, buildZipFile, stagingDir, force);
}

return true
} catch (e) {
self.logger.showUserError(e)
}
Expand All @@ -118,11 +120,45 @@ export class NodeCommand extends BaseCommand {
}

async start(argv) {
const self = this

try {
const namespace = argv.namespace
const nodeIDsArg = argv.nodeIds ? argv.nodeIds.split(',') : []
let {podNames, nodeIDs} = await this.checkNetworkNodePods(namespace, nodeIDsArg)
for (const podName of podNames) {
self.logger.showUser(chalk.cyan('>>'), `Starting node ${podName}`)
await self.kubectl.execContainer(podName, constants.ROOT_CONTAINER, 'systemctl restart network-node')
self.logger.showUser(chalk.green('OK'), `Started node ${podName}`)
}

return true
} catch (e) {
self.logger.showUserError(e)
}

return false
}

async stop(argv) {
const self = this

try {
const namespace = argv.namespace
const nodeIDsArg = argv.nodeIds ? argv.nodeIds.split(',') : []
let {podNames, nodeIDs} = await this.checkNetworkNodePods(namespace, nodeIDsArg)
for (const podName of podNames) {
self.logger.showUser(chalk.cyan('>>'), `Stopping node ${podName}`)
await self.kubectl.execContainer(podName, constants.ROOT_CONTAINER, 'systemctl restart network-node')
self.logger.showUser(chalk.green('OK'), `Stopped node ${podName}`)
}

return true
} catch (e) {
self.logger.showUserError(e)
}

return false
}

/**
Expand Down Expand Up @@ -161,6 +197,7 @@ export class NodeCommand extends BaseCommand {
command: 'start',
desc: 'Start a node running Hedera platform',
builder: yargs => {
yargs.option('namespace', flags.namespaceFlag)
yargs.option('node-ids', flags.nodeIDs)
},
handler: argv => {
Expand All @@ -181,6 +218,7 @@ export class NodeCommand extends BaseCommand {
command: 'stop',
desc: 'stop a node running Hedera platform',
builder: yargs => {
yargs.option('namespace', flags.namespaceFlag)
yargs.option('node-ids', flags.nodeIDs)
},
handler: argv => {
Expand Down

0 comments on commit 9883fa7

Please sign in to comment.