diff --git a/confluent_client/bin/nodeconsole b/confluent_client/bin/nodeconsole index 25e190b2..e9bd6b1e 100755 --- a/confluent_client/bin/nodeconsole +++ b/confluent_client/bin/nodeconsole @@ -39,7 +39,7 @@ argparser.add_option('-t', '--tile', action='store_true', default=False, argparser.add_option('-l', '--log', action='store_true', default=False, help='Enter log replay mode instead of showing a live console') argparser.add_option('-w','--windowed', action='store_true', default=False, - help='Open terminal windows for each node') + help='Open terminal windows for each node. The environment variable NODECONSOLE_WINDOWED_COMMAND must be set, which should be a text string corresponding to a command that can be used to open a windowed console, omitting the "nodeconsole " part of the command, for example, to open a set of consoles for a range of nodes in separate xterm windows, set NODECONSOLE_WINDOWED_COMMAND to "xterm -e", or in a WSL environment, to open a set of consoles for a range of nodes in separate Windows Terminal windows, with the title set for each node, set NODECONSOLE_WINDOWED_COMMAND to "wt.exe --title node wsl.exe -d AlmaLinux-8 --shell-type login". Note that "node" when in the NODECONSOLE_WINDOWED_COMMAND environment variable is treated as a keyword, not a literal.') (options, args) = argparser.parse_args() if len(args) != 1: argparser.print_help() @@ -55,6 +55,7 @@ if options.log: sys.exit(0) #added functionality for wcons if options.windowed: + envlist=os.environ.get('NODECONSOLE_WINDOWED_COMMAND').split(' ') nodes = [] sess = client.Command() for res in sess.read('/noderange/{0}/nodes/'.format(args[0])): @@ -63,9 +64,13 @@ if options.windowed: sys.stderr.write(res.get('error', repr(res)) + '\n') sys.exit(1) nodes.append(node) + # Hack to deal with messed up terminal after starting wt.exe using subprocess.Popen in WSL - AHW 10/15/22 + sttyg = subprocess.run(['stty', '-g'], stdout=subprocess.PIPE, universal_newlines=True) for node in sortutil.natural_sort(nodes): - sub = subprocess.Popen(['xterm', '-e', 'nodeconsole', node]) - out,err = sub.communicate() + subprocess.Popen(envlist + [confettypath, '-m', '5', 'start', '/nodes/{0}/console/session'.format(node)]) + # Hack to deal with messed up terminal after starting wt.exe using subprocess.Popen in WSL - AHW 10/15/22 + subprocess.run(['stty', '{0}'.format(sttyg.stdout.strip("\n"))]) + sys.exit(0) #end of wcons if options.tile: null = open('/dev/null', 'w')