mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
support listen random port. #524
This commit is contained in:
@@ -27,6 +27,7 @@ import com.alibaba.arthas.deps.org.slf4j.LoggerFactory;
|
||||
import com.alibaba.arthas.tunnel.client.TunnelClient;
|
||||
import com.taobao.arthas.common.AnsiLog;
|
||||
import com.taobao.arthas.common.PidUtils;
|
||||
import com.taobao.arthas.common.SocketUtils;
|
||||
import com.taobao.arthas.core.advisor.TransformerManager;
|
||||
import com.taobao.arthas.core.command.BuiltinCommandPack;
|
||||
import com.taobao.arthas.core.command.view.ResultViewResolver;
|
||||
@@ -274,6 +275,18 @@ public class ArthasBootstrap {
|
||||
throw new IllegalStateException("already bind");
|
||||
}
|
||||
|
||||
// init random port
|
||||
if (configure.getTelnetPort() == 0) {
|
||||
int newTelnetPort = SocketUtils.findAvailableTcpPort();
|
||||
configure.setTelnetPort(newTelnetPort);
|
||||
logger().info("generate random telnet port: " + newTelnetPort);
|
||||
}
|
||||
if (configure.getHttpPort() == 0) {
|
||||
int newHttpPort = SocketUtils.findAvailableTcpPort();
|
||||
configure.setHttpPort(newHttpPort);
|
||||
logger().info("generate random http port: " + newHttpPort);
|
||||
}
|
||||
|
||||
String agentId = null;
|
||||
try {
|
||||
if (configure.getTunnelServer() != null && configure.getHttpPort() > 0) {
|
||||
|
||||
Reference in New Issue
Block a user