Skip to content

Commit

Permalink
remove shutdown command. close #1799
Browse files Browse the repository at this point in the history
  • Loading branch information
hengyunabc committed Jun 10, 2021
1 parent b17a0cd commit 03f2994
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.taobao.arthas.core.command;

import java.util.ArrayList;
import java.util.List;

import com.taobao.arthas.core.command.basic1000.AuthCommand;
import com.taobao.arthas.core.command.basic1000.Base64Command;
import com.taobao.arthas.core.command.basic1000.CatCommand;
import com.taobao.arthas.core.command.basic1000.ClsCommand;
Expand All @@ -9,12 +13,9 @@
import com.taobao.arthas.core.command.basic1000.HistoryCommand;
import com.taobao.arthas.core.command.basic1000.KeymapCommand;
import com.taobao.arthas.core.command.basic1000.OptionsCommand;
import com.alibaba.bytekit.utils.AnnotationUtils;
import com.taobao.arthas.core.command.basic1000.AuthCommand;
import com.taobao.arthas.core.command.basic1000.PwdCommand;
import com.taobao.arthas.core.command.basic1000.ResetCommand;
import com.taobao.arthas.core.command.basic1000.SessionCommand;
import com.taobao.arthas.core.command.basic1000.ShutdownCommand;
import com.taobao.arthas.core.command.basic1000.StopCommand;
import com.taobao.arthas.core.command.basic1000.SystemEnvCommand;
import com.taobao.arthas.core.command.basic1000.SystemPropertyCommand;
Expand Down Expand Up @@ -52,9 +53,6 @@
import com.taobao.arthas.core.shell.command.CommandResolver;
import com.taobao.middleware.cli.annotations.Name;

import java.util.ArrayList;
import java.util.List;

/**
* TODO automatically discover the built-in commands.
* @author beiwei30 on 17/11/2016.
Expand Down Expand Up @@ -119,7 +117,6 @@ private void initCommands(List<String> disabledCommands) {
commandClassList.add(TeeCommand.class);
commandClassList.add(ProfilerCommand.class);
commandClassList.add(VmToolCommand.class);
commandClassList.add(ShutdownCommand.class);
commandClassList.add(StopCommand.class);

for (Class<? extends AnnotatedCommand> clazz : commandClassList) {
Expand Down

This file was deleted.

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();
}
}
}

0 comments on commit 03f2994

Please sign in to comment.