From 1c9144a5a05240bc32c0dc024b1702cd04fe1912 Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Wed, 14 Jul 2021 16:58:00 +0800 Subject: [PATCH] support ARTHAS_LIB_DIR env. close #1861 --- bin/as.sh | 4 +++- .../main/java/com/taobao/arthas/boot/Bootstrap.java | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/as.sh b/bin/as.sh index 1edce18c2..6f2e26d4c 100755 --- a/bin/as.sh +++ b/bin/as.sh @@ -83,7 +83,9 @@ DIR=$(dirname -- "$(rreadlink "${BASH_SOURCE[0]}")") ARTHAS_HOME= # define arthas's lib -ARTHAS_LIB_DIR=${HOME}/.arthas/lib +if [ -z "${ARTHAS_LIB_DIR}" ]; then + ARTHAS_LIB_DIR=${HOME}/.arthas/lib +fi # target process id to attach TARGET_PID= 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 75f73ade6..fb23af229 100644 --- a/boot/src/main/java/com/taobao/arthas/boot/Bootstrap.java +++ b/boot/src/main/java/com/taobao/arthas/boot/Bootstrap.java @@ -132,8 +132,14 @@ public class Bootstrap { private String disabledCommands; static { - ARTHAS_LIB_DIR = new File( - System.getProperty("user.home") + File.separator + ".arthas" + File.separator + "lib"); + String arthasLibDirEnv = System.getenv("ARTHAS_LIB_DIR"); + if (arthasLibDirEnv != null) { + ARTHAS_LIB_DIR = new File(arthasLibDirEnv); + } else { + ARTHAS_LIB_DIR = new File( + System.getProperty("user.home") + File.separator + ".arthas" + File.separator + "lib"); + } + try { ARTHAS_LIB_DIR.mkdirs(); } catch (Throwable t) {