mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
support session timeout config. #296
This commit is contained in:
@@ -4,6 +4,7 @@ import com.sun.tools.attach.VirtualMachine;
|
||||
import com.sun.tools.attach.VirtualMachineDescriptor;
|
||||
import com.taobao.arthas.common.AnsiLog;
|
||||
import com.taobao.arthas.core.config.Configure;
|
||||
import com.taobao.arthas.core.shell.ShellServerOptions;
|
||||
import com.taobao.middleware.cli.CLI;
|
||||
import com.taobao.middleware.cli.CLIs;
|
||||
import com.taobao.middleware.cli.CommandLine;
|
||||
@@ -34,14 +35,17 @@ public class Arthas {
|
||||
.setShortName("telnet-port").setDefaultValue(DEFAULT_TELNET_PORT);
|
||||
Option httpPort = new TypedOption<Integer>().setType(Integer.class)
|
||||
.setShortName("http-port").setDefaultValue(DEFAULT_HTTP_PORT);
|
||||
Option sessionTimeout = new TypedOption<Integer>().setType(Integer.class)
|
||||
.setShortName("session-timeout").setDefaultValue("" + ShellServerOptions.DEFAULT_SESSION_TIMEOUT);
|
||||
CLI cli = CLIs.create("arthas").addOption(pid).addOption(core).addOption(agent).addOption(target)
|
||||
.addOption(telnetPort).addOption(httpPort);
|
||||
.addOption(telnetPort).addOption(httpPort).addOption(sessionTimeout);
|
||||
CommandLine commandLine = cli.parse(Arrays.asList(args));
|
||||
|
||||
Configure configure = new Configure();
|
||||
configure.setJavaPid((Integer) commandLine.getOptionValue("pid"));
|
||||
configure.setArthasAgent((String) commandLine.getOptionValue("agent"));
|
||||
configure.setArthasCore((String) commandLine.getOptionValue("core"));
|
||||
configure.setSessionTimeout((Integer)commandLine.getOptionValue("session-timeout"));
|
||||
if (commandLine.getOptionValue("target-ip") == null) {
|
||||
throw new IllegalStateException("as.sh is too old to support web console, " +
|
||||
"please run the following command to upgrade to latest version:" +
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.taobao.arthas.core.config;
|
||||
|
||||
import com.taobao.arthas.core.shell.ShellServerOptions;
|
||||
import com.taobao.arthas.core.util.reflect.ArthasReflectUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -12,6 +13,7 @@ import static java.lang.reflect.Modifier.isStatic;
|
||||
* 配置类
|
||||
*
|
||||
* @author vlinux
|
||||
* @author hengyunabc 2018-11-12
|
||||
*/
|
||||
public class Configure {
|
||||
|
||||
@@ -22,6 +24,12 @@ public class Configure {
|
||||
private String arthasCore;
|
||||
private String arthasAgent;
|
||||
|
||||
/**
|
||||
* session timeout seconds
|
||||
* @see com.taobao.arthas.core.shell.ShellServerOptions#DEFAULT_SESSION_TIMEOUT
|
||||
*/
|
||||
private long sessionTimeout = ShellServerOptions.DEFAULT_SESSION_TIMEOUT/1000;
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
@@ -70,6 +78,14 @@ public class Configure {
|
||||
this.arthasCore = arthasCore;
|
||||
}
|
||||
|
||||
public long getSessionTimeout() {
|
||||
return sessionTimeout;
|
||||
}
|
||||
|
||||
public void setSessionTimeout(long sessionTimeout) {
|
||||
this.sessionTimeout = sessionTimeout;
|
||||
}
|
||||
|
||||
// 对象的编码解码器
|
||||
private final static FeatureCodec codec = new FeatureCodec(';', '=');
|
||||
|
||||
|
||||
@@ -79,7 +79,10 @@ public class ArthasBootstrap {
|
||||
}
|
||||
|
||||
try {
|
||||
ShellServerOptions options = new ShellServerOptions().setInstrumentation(instrumentation).setPid(pid);
|
||||
ShellServerOptions options = new ShellServerOptions()
|
||||
.setInstrumentation(instrumentation)
|
||||
.setPid(pid)
|
||||
.setSessionTimeout(configure.getSessionTimeout() * 1000);
|
||||
shellServer = new ShellServerImpl(options, this);
|
||||
BuiltinCommandPack builtinCommands = new BuiltinCommandPack();
|
||||
List<CommandResolver> resolvers = new ArrayList<CommandResolver>();
|
||||
|
||||
Reference in New Issue
Block a user