From aee79ef7b435944372ffc6417964066f9c2055e9 Mon Sep 17 00:00:00 2001 From: John Niang Date: Mon, 15 Jun 2020 23:43:02 +0800 Subject: [PATCH] Remove restart feature (#917) * Ignore application-local file * Remove restart feature --- .gitignore | 17 +++++++++------ src/main/java/run/halo/app/Application.java | 21 +------------------ .../controller/admin/api/AdminController.java | 5 +++-- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 46c85f0b8..13a5efbba 100755 --- a/.gitignore +++ b/.gitignore @@ -42,19 +42,19 @@ nbdist/ *.project *.factorypath -# Compiled class file +### Compiled class file *.class -# Log file +### Log file *.log -# BlueJ files +### BlueJ files *.ctxt -# Mobile Tools for Java (J2ME) +### Mobile Tools for Java (J2ME) .mtj.tmp/ -# Package Files # +### Package Files *.war *.nar *.ear @@ -63,4 +63,9 @@ nbdist/ *.rar ### VSCode -.vscode \ No newline at end of file +.vscode + +### Local file +application-local.yml +application-local.yaml +application-local.properties \ No newline at end of file diff --git a/src/main/java/run/halo/app/Application.java b/src/main/java/run/halo/app/Application.java index 3b171a1e6..d023387fe 100755 --- a/src/main/java/run/halo/app/Application.java +++ b/src/main/java/run/halo/app/Application.java @@ -1,11 +1,9 @@ package run.halo.app; -import org.springframework.boot.ApplicationArguments; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; -import org.springframework.context.ConfigurableApplicationContext; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.scheduling.annotation.EnableAsync; import run.halo.app.repository.base.BaseRepositoryImpl; @@ -21,29 +19,12 @@ import run.halo.app.repository.base.BaseRepositoryImpl; @EnableJpaRepositories(basePackages = "run.halo.app.repository", repositoryBaseClass = BaseRepositoryImpl.class) public class Application extends SpringBootServletInitializer { - private static ConfigurableApplicationContext CONTEXT; - public static void main(String[] args) { // Customize the spring config location System.setProperty("spring.config.additional-location", "file:${user.home}/.halo/,file:${user.home}/halo-dev/"); // Run application - CONTEXT = SpringApplication.run(Application.class, args); - } - - /** - * Restart Application. - */ - public static void restart() { - ApplicationArguments args = CONTEXT.getBean(ApplicationArguments.class); - - Thread thread = new Thread(() -> { - CONTEXT.close(); - CONTEXT = SpringApplication.run(Application.class, args.getSourceArgs()); - }); - - thread.setDaemon(false); - thread.start(); + SpringApplication.run(Application.class, args); } @Override diff --git a/src/main/java/run/halo/app/controller/admin/api/AdminController.java b/src/main/java/run/halo/app/controller/admin/api/AdminController.java index c291361f3..c3b99acfd 100644 --- a/src/main/java/run/halo/app/controller/admin/api/AdminController.java +++ b/src/main/java/run/halo/app/controller/admin/api/AdminController.java @@ -4,9 +4,9 @@ import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; -import run.halo.app.Application; import run.halo.app.annotation.DisableOnCondition; import run.halo.app.cache.lock.CacheLock; +import run.halo.app.exception.BadRequestException; import run.halo.app.model.dto.EnvironmentDTO; import run.halo.app.model.dto.LoginPreCheckDTO; import run.halo.app.model.dto.StatisticDTO; @@ -131,8 +131,9 @@ public class AdminController { @PostMapping(value = {"halo/restart", "spring/restart"}) @ApiOperation("Restarts halo server") @DisableOnCondition + @Deprecated public void restartApplication() { - Application.restart(); + throw new BadRequestException("此前的重启方案存在性能问题,故暂不支持重启功能!"); } @GetMapping(value = "halo/logfile")