Add --keep-open option to clusterctl

Add option to keep the console log open after starting an instance
instead of exiting as soon as it has finished starting up.
This commit is contained in:
Hornwitser committed 2020-07-06 13:16:57 +02:00
1 parent 8c6130adba
commit 999386c088
1 file changed
+7 -1
+7 -1
View File
@@ -383,6 +383,7 @@ commands.push(new Command({
yargs.options({ yargs.options({
"instance": { describe: "Instance to start", nargs: 1, type: "string", demandOption: true }, "instance": { describe: "Instance to start", nargs: 1, type: "string", demandOption: true },
"save": { describe: "Save load, defaults to latest", nargs: 1, type: "string" }, "save": { describe: "Save load, defaults to latest", nargs: 1, type: "string" },
"keep-open": { describe: "Keep console open", nargs: 0, type: "boolean", default: false },
}); });
}], }],
handler: async function(args, control) { handler: async function(args, control) {
@@ -400,6 +401,7 @@ commands.push(new Command({
yargs.options({ yargs.options({
"instance": { describe: "Instance to start", nargs: 1, type: "string", demandOption: true }, "instance": { describe: "Instance to start", nargs: 1, type: "string", demandOption: true },
"scenario": { describe: "Scenario to load", nargs: 1, type: "string" }, "scenario": { describe: "Scenario to load", nargs: 1, type: "string" },
"keep-open": { describe: "Keep console open", nargs: 0, type: "boolean", default: false },
}); });
}], }],
handler: async function(args, control) { handler: async function(args, control) {
@@ -752,10 +754,12 @@ async function startControl() {
if (commands.has(commandName)) { if (commands.has(commandName)) {
let command = commands.get(commandName); let command = commands.get(commandName);
let keepOpen = Boolean(args.keepOpen);
try { try {
await command.run(args, control); await command.run(args, control);
} catch (err) { } catch (err) {
keepOpen = false;
if (err instanceof errors.CommandError) { if (err instanceof errors.CommandError) {
console.error(`Error running command: ${err.message}`); console.error(`Error running command: ${err.message}`);
process.exitCode = 1; process.exitCode = 1;
@@ -769,7 +773,9 @@ async function startControl() {
} }
} finally { } finally {
await control.shutdown(); if (!keepOpen) {
await control.shutdown();
}
} }
} }
} }