From 999386c0880b635781fb5da60ec385bdbbeffe8c Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Mon, 6 Jul 2020 13:16:57 +0200 Subject: [PATCH] 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. --- clusterctl.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clusterctl.js b/clusterctl.js index 5c439438..fe3ddc9b 100644 --- a/clusterctl.js +++ b/clusterctl.js @@ -383,6 +383,7 @@ commands.push(new Command({ yargs.options({ "instance": { describe: "Instance to start", nargs: 1, type: "string", demandOption: true }, "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) { @@ -400,6 +401,7 @@ commands.push(new Command({ yargs.options({ "instance": { describe: "Instance to start", nargs: 1, type: "string", demandOption: true }, "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) { @@ -752,10 +754,12 @@ async function startControl() { if (commands.has(commandName)) { let command = commands.get(commandName); + let keepOpen = Boolean(args.keepOpen); try { await command.run(args, control); } catch (err) { + keepOpen = false; if (err instanceof errors.CommandError) { console.error(`Error running command: ${err.message}`); process.exitCode = 1; @@ -769,7 +773,9 @@ async function startControl() { } } finally { - await control.shutdown(); + if (!keepOpen) { + await control.shutdown(); + } } } }