From 280fac704cb875cbfc14012da295b064f3788fe8 Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Wed, 19 Sep 2018 19:31:12 +0800 Subject: [PATCH] update as.sh to support --versions --- CONTRIBUTING.md | 18 +++++++++++++++++- bin/as.sh | 16 +++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d01bf4ebc..552df1b3a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,9 @@ ## 改进用户文档 -用户文档在`site/src/site/sphinx`目录下,如果希望改进arthas用户文档,可以提交PR。 +用户文档在`site/src/site/sphinx`目录下,如果希望改进arthas用户文档,欢迎提交PR。 + +英文文档在`site/src/site/sphinx/en`目录下,欢迎提交翻译PR。 ## 开发者相关 @@ -23,6 +25,20 @@ 也可以直接 `./mvnw clean package -DskipTests`打包,生成的zip在 `packaging/target/` 下面。但是注意`as.sh`启动加载的是`~/.arthas/lib`下面的版本。 +### 启动指定版本的arthas + +本地开发时,可能会产生多个版本,可以用 `--use-version` 参数来指定版本,比如 + +```bash +./as.sh --use-version 3.0.5.20180919185025 +``` + +可以用`--versions`参数来列出所有版本: + +```bash +./as.sh --versions +``` + ### Debug Arthas启动过程分为两部分: diff --git a/bin/as.sh b/bin/as.sh index ba2920c1f..df49ebc7d 100755 --- a/bin/as.sh +++ b/bin/as.sh @@ -204,6 +204,7 @@ Usage: [-f] : specify the path to batch script file. [--attach-only] : only attach the arthas agent to target jvm. [--use-version] : use the specified arthas version to attach. + [--versions] : list all arthas versions. Example: ./as.sh @@ -213,7 +214,8 @@ Example: ./as.sh -b ./as.sh -b -f /path/to/script ./as.sh --attach-only - ./as.sh --use-version 2.0.20161221142407 + ./as.sh --use-version 3.0.5.20180919185025 + ./as.sh --versions Here is the list of possible java process(es) to attatch: @@ -221,6 +223,13 @@ $(${JAVA_HOME}/bin/jps -l | grep -v sun.tools.jps.Jps) " } +# list arthas versions +list_versions() +{ + echo "Arthas versions under ${ARTHAS_LIB_DIR}:" + ls -1 ${ARTHAS_LIB_DIR} +} + # parse the argument parse_arguments() { @@ -229,6 +238,11 @@ parse_arguments() exit 0 fi + if ([ "$1" = "--versions" ]) ; then + list_versions + exit 0 + fi + if [ "$1" = "-b" ]; then BATCH_MODE=true shift