-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove shutdown command. close #1799
- Loading branch information
1 parent
b17a0cd
commit 03f2994
Showing
3 changed files
with
29 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
core/src/main/java/com/taobao/arthas/core/command/basic1000/ShutdownCommand.java
This file was deleted.
Oops, something went wrong.
28 changes: 25 additions & 3 deletions
28
core/src/main/java/com/taobao/arthas/core/command/basic1000/StopCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,42 @@ | ||
package com.taobao.arthas.core.command.basic1000; | ||
|
||
import com.alibaba.arthas.deps.org.slf4j.Logger; | ||
import com.alibaba.arthas.deps.org.slf4j.LoggerFactory; | ||
import com.taobao.arthas.core.command.model.MessageModel; | ||
import com.taobao.arthas.core.command.model.ResetModel; | ||
import com.taobao.arthas.core.command.model.ShutdownModel; | ||
import com.taobao.arthas.core.server.ArthasBootstrap; | ||
import com.taobao.arthas.core.shell.command.AnnotatedCommand; | ||
import com.taobao.arthas.core.shell.command.CommandProcess; | ||
import com.taobao.arthas.core.util.affect.EnhancerAffect; | ||
import com.taobao.middleware.cli.annotations.Name; | ||
import com.taobao.middleware.cli.annotations.Summary; | ||
|
||
/** | ||
* Alias for ShutdownCommand | ||
* @author hengyunabc 2019-07-05 | ||
* @see ShutdownCommand | ||
*/ | ||
@Name("stop") | ||
@Summary("Stop/Shutdown Arthas server and exit the console.") | ||
public class StopCommand extends AnnotatedCommand { | ||
private static final Logger logger = LoggerFactory.getLogger(StopCommand.class); | ||
@Override | ||
public void process(CommandProcess process) { | ||
ShutdownCommand.shutdown(process); | ||
shutdown(process); | ||
} | ||
private static void shutdown(CommandProcess process) { | ||
ArthasBootstrap arthasBootstrap = ArthasBootstrap.getInstance(); | ||
try { | ||
// 退出之前需要重置所有的增强类 | ||
process.appendResult(new MessageModel("Resetting all enhanced classes ...")); | ||
EnhancerAffect enhancerAffect = arthasBootstrap.reset(); | ||
process.appendResult(new ResetModel(enhancerAffect)); | ||
process.appendResult(new ShutdownModel(true, "Arthas Server is going to shutdown...")); | ||
} catch (Throwable e) { | ||
logger.error("An error occurred when stopping arthas server.", e); | ||
process.appendResult(new ShutdownModel(false, "An error occurred when stopping arthas server.")); | ||
} finally { | ||
process.end(); | ||
arthasBootstrap.destroy(); | ||
} | ||
} | ||
} |