Skip to content

Commit

Permalink
arthas-boot set arthas lib to /tmp/.arthas/lib, when user.home is not…
Browse files Browse the repository at this point in the history
… writeable. alibaba#572
  • Loading branch information
hengyunabc committed May 10, 2019
1 parent 89e22d5 commit ce790a3
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions boot/src/main/java/com/taobao/arthas/boot/Bootstrap.java
Expand Up @@ -53,8 +53,7 @@ public class Bootstrap {
private static final int DEFAULT_TELNET_PORT = 3658;
private static final int DEFAULT_HTTP_PORT = 8563;
private static final String DEFAULT_TARGET_IP = "127.0.0.1";
private static final File ARTHAS_LIB_DIR = new File(
System.getProperty("user.home") + File.separator + ".arthas" + File.separator + "lib");
private static File ARTHAS_LIB_DIR;

private boolean help = false;

Expand Down Expand Up @@ -107,6 +106,28 @@ public class Bootstrap {
private String command;
private String batchFile;

static {
ARTHAS_LIB_DIR = new File(
System.getProperty("user.home") + File.separator + ".arthas" + File.separator + "lib");
try {
ARTHAS_LIB_DIR.mkdirs();
} catch (Throwable t) {
//ignore
}
if (!ARTHAS_LIB_DIR.exists()) {
// try to set a temp directory
ARTHAS_LIB_DIR = new File(System.getProperty("java.io.tmpdir") + File.separator + ".arthas" + File.separator + "lib");
try {
ARTHAS_LIB_DIR.mkdirs();
} catch (Throwable e) {
// ignore
}
}
if (!ARTHAS_LIB_DIR.exists()) {
System.err.println("Can not find directory to save arthas lib. please try to set user home by -Duser.home=");
}
}

@Argument(argName = "pid", index = 0, required = false)
@Description("Target pid")
public void setPid(int pid) {
Expand Down

0 comments on commit ce790a3

Please sign in to comment.