mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
@@ -71,7 +71,7 @@ public class AgentBootstrap {
|
||||
/**
|
||||
* 让下次再次启动时有机会重新加载
|
||||
*/
|
||||
public synchronized static void resetArthasClassLoader() {
|
||||
public static void resetArthasClassLoader() {
|
||||
arthasClassLoader = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -352,6 +352,9 @@ public class ArthasBootstrap {
|
||||
}
|
||||
|
||||
shellServer.listen(new BindHandler(isBindRef));
|
||||
if (!isBind()) {
|
||||
throw new IllegalStateException("Arthas failed to bind telnet or http port.");
|
||||
}
|
||||
|
||||
//http api session manager
|
||||
sessionManager = new SessionManagerImpl(options, shellServer.getCommandManager(), shellServer.getJobController());
|
||||
@@ -376,14 +379,8 @@ public class ArthasBootstrap {
|
||||
|
||||
logger().info("as-server started in {} ms", System.currentTimeMillis() - start);
|
||||
} catch (Throwable e) {
|
||||
logger().error("Error during bind to port " + configure.getTelnetPort(), e);
|
||||
if (shellServer != null) {
|
||||
shellServer.close();
|
||||
}
|
||||
if (sessionManager != null){
|
||||
sessionManager.close();
|
||||
}
|
||||
shutdownWorkGroup();
|
||||
logger().error("Error during start as-server", e);
|
||||
destroy();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -412,7 +409,17 @@ public class ArthasBootstrap {
|
||||
* call reset() before destroy()
|
||||
*/
|
||||
public void destroy() {
|
||||
timer.cancel();
|
||||
if (shellServer != null) {
|
||||
shellServer.close();
|
||||
shellServer = null;
|
||||
}
|
||||
if (sessionManager != null) {
|
||||
sessionManager.close();
|
||||
sessionManager = null;
|
||||
}
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
}
|
||||
if (this.tunnelClient != null) {
|
||||
try {
|
||||
tunnelClient.stop();
|
||||
@@ -420,41 +427,27 @@ public class ArthasBootstrap {
|
||||
logger().error("stop tunnel client error", e);
|
||||
}
|
||||
}
|
||||
transformerManager.destroy();
|
||||
UserStatUtil.destroy();
|
||||
if (executorService != null) {
|
||||
executorService.shutdownNow();
|
||||
}
|
||||
if (transformerManager != null) {
|
||||
transformerManager.destroy();
|
||||
}
|
||||
// clear the reference in Spy class.
|
||||
cleanUpSpyReference();
|
||||
try {
|
||||
Runtime.getRuntime().removeShutdownHook(shutdown);
|
||||
} catch (Throwable t) {
|
||||
// ignore
|
||||
shutdownWorkGroup();
|
||||
UserStatUtil.destroy();
|
||||
if (shutdown != null) {
|
||||
try {
|
||||
Runtime.getRuntime().removeShutdownHook(shutdown);
|
||||
} catch (Throwable t) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
logger().info("as-server destroy completed.");
|
||||
if (loggerContext != null) {
|
||||
loggerContext.stop();
|
||||
}
|
||||
|
||||
if (sessionManager != null){
|
||||
try {
|
||||
sessionManager.close();
|
||||
} catch (Throwable e) {
|
||||
logger().error("close session manager failure", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (shellServer != null) {
|
||||
try {
|
||||
shellServer.close();
|
||||
} catch (Throwable e) {
|
||||
logger().error("close shell server failure", e);
|
||||
}
|
||||
}
|
||||
|
||||
shellServer = null;
|
||||
sessionManager = null;
|
||||
|
||||
executorService.shutdownNow();
|
||||
shutdownWorkGroup();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ public class SessionManagerImpl implements SessionManager {
|
||||
scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
final Thread t = new Thread(r, "arthas-shell-server");
|
||||
final Thread t = new Thread(r, "arthas-session-manager");
|
||||
t.setDaemon(true);
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class EnhancerTest {
|
||||
|
||||
TestHelper.appendSpyJar(instrumentation);
|
||||
|
||||
ArthasBootstrap.getInstance(instrumentation, "");
|
||||
ArthasBootstrap.getInstance(instrumentation, "ip=127.0.0.1");
|
||||
|
||||
AdviceListener listener = Mockito.mock(AdviceListener.class);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user