From 0eb32d09807a12d293c07420019c11f95ec9fe99 Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Wed, 13 Feb 2019 21:27:48 +0800 Subject: [PATCH] as.sh/arthas-boot support width/height options. close #422 --- bin/as.sh | 29 +++++++++++++++++ .../com/taobao/arthas/boot/Bootstrap.java | 31 +++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/bin/as.sh b/bin/as.sh index 96256d0f1..c1fa58696 100755 --- a/bin/as.sh +++ b/bin/as.sh @@ -53,6 +53,11 @@ ATTACH_ONLY=false # pass debug arguments to the attach java process DEBUG_ATTACH=false +# arthas-client terminal height +HEIGHT= +# arthas-client terminal width +WIDTH= + # Verbose, print debug info. VERBOSE=false @@ -410,6 +415,8 @@ Options and Arguments: -c,--command Command to execute, multiple commands separated by ; -f,--batch-file The batch file to execute + --height arthas-client terminal height + --width arthas-client terminal width -v,--verbose Verbose, print debug info. Target pid @@ -537,6 +544,16 @@ parse_arguments() ARTHAS_OPTS="$JPDA_OPTS $ARTHAS_OPTS" shift # past argument ;; + --height) + HEIGHT="$2" + shift # past argument + shift # past value + ;; + --width) + WIDTH="$2" + shift # past argument + shift # past value + ;; -v|--verbose) VERBOSE=true shift # past argument @@ -730,11 +747,22 @@ active_console() fi if [ "${BATCH_MODE}" = "true" ]; then + local tempArgs=() + if [ "${HEIGHT}" ]; then + tempArgs+=("--height") + tempArgs+=("${HEIGHT}") + fi + if [ "${WIDTH}" ]; then + tempArgs+=("--width") + tempArgs+=("${WIDTH}") + fi + if [ "${COMMAND}" ] ; then "${JAVA_HOME}/bin/java" ${ARTHAS_OPTS} ${JVM_OPTS} \ -jar "${arthas_lib_dir}/arthas-client.jar" \ ${TARGET_IP} \ ${TELNET_PORT} \ + "${tempArgs[@]}" \ -c ${COMMAND} fi if [ "${BATCH_FILE}" ] ; then @@ -742,6 +770,7 @@ active_console() -jar "${arthas_lib_dir}/arthas-client.jar" \ ${TARGET_IP} \ ${TELNET_PORT} \ + "${tempArgs[@]}" \ -f ${BATCH_FILE} fi elif type telnet 2>&1 >> /dev/null; then diff --git a/boot/src/main/java/com/taobao/arthas/boot/Bootstrap.java b/boot/src/main/java/com/taobao/arthas/boot/Bootstrap.java index d9cade16a..676bbc4e6 100644 --- a/boot/src/main/java/com/taobao/arthas/boot/Bootstrap.java +++ b/boot/src/main/java/com/taobao/arthas/boot/Bootstrap.java @@ -67,6 +67,9 @@ public class Bootstrap { */ private Long sessionTimeout; + private Integer height = null; + private Integer width = null; + private boolean verbose = false; /** @@ -188,6 +191,18 @@ public class Bootstrap { this.batchFile = batchFile; } + @Option(longName = "height") + @Description("arthas-client terminal height") + public void setHeight(int height) { + this.height = height; + } + + @Option(longName = "width") + @Description("arthas-client terminal width") + public void setWidth(int width) { + this.width = width; + } + @Option(shortName = "v", longName = "verbose", flag = true) @Description("Verbose, print debug info.") public void setVerbose(boolean verbose) { @@ -448,6 +463,14 @@ public class Bootstrap { telnetArgs.add("-f"); telnetArgs.add(bootstrap.getBatchFile()); } + if (bootstrap.getHeight() != null) { + telnetArgs.add("--height"); + telnetArgs.add("" + bootstrap.getHeight()); + } + if (bootstrap.getWidth() != null) { + telnetArgs.add("--width"); + telnetArgs.add("" + bootstrap.getWidth()); + } // telnet port ,ip telnetArgs.add(bootstrap.getTargetIp()); @@ -581,4 +604,12 @@ public class Bootstrap { public boolean isVersions() { return versions; } + + public Integer getHeight() { + return height; + } + + public Integer getWidth() { + return width; + } }