Remove restart feature (#917)

* Ignore application-local file

* Remove restart feature
pull/918/head
John Niang 2020-06-15 23:43:02 +08:00 committed by GitHub
parent 658f0a2b3f
commit aee79ef7b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 28 deletions

17
.gitignore vendored
View File

@ -42,19 +42,19 @@ nbdist/
*.project *.project
*.factorypath *.factorypath
# Compiled class file ### Compiled class file
*.class *.class
# Log file ### Log file
*.log *.log
# BlueJ files ### BlueJ files
*.ctxt *.ctxt
# Mobile Tools for Java (J2ME) ### Mobile Tools for Java (J2ME)
.mtj.tmp/ .mtj.tmp/
# Package Files # ### Package Files
*.war *.war
*.nar *.nar
*.ear *.ear
@ -63,4 +63,9 @@ nbdist/
*.rar *.rar
### VSCode ### VSCode
.vscode .vscode
### Local file
application-local.yml
application-local.yaml
application-local.properties

View File

@ -1,11 +1,9 @@
package run.halo.app; package run.halo.app;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import run.halo.app.repository.base.BaseRepositoryImpl; 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) @EnableJpaRepositories(basePackages = "run.halo.app.repository", repositoryBaseClass = BaseRepositoryImpl.class)
public class Application extends SpringBootServletInitializer { public class Application extends SpringBootServletInitializer {
private static ConfigurableApplicationContext CONTEXT;
public static void main(String[] args) { public static void main(String[] args) {
// Customize the spring config location // Customize the spring config location
System.setProperty("spring.config.additional-location", "file:${user.home}/.halo/,file:${user.home}/halo-dev/"); System.setProperty("spring.config.additional-location", "file:${user.home}/.halo/,file:${user.home}/halo-dev/");
// Run application // Run application
CONTEXT = SpringApplication.run(Application.class, args); 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();
} }
@Override @Override

View File

@ -4,9 +4,9 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import run.halo.app.Application;
import run.halo.app.annotation.DisableOnCondition; import run.halo.app.annotation.DisableOnCondition;
import run.halo.app.cache.lock.CacheLock; 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.EnvironmentDTO;
import run.halo.app.model.dto.LoginPreCheckDTO; import run.halo.app.model.dto.LoginPreCheckDTO;
import run.halo.app.model.dto.StatisticDTO; import run.halo.app.model.dto.StatisticDTO;
@ -131,8 +131,9 @@ public class AdminController {
@PostMapping(value = {"halo/restart", "spring/restart"}) @PostMapping(value = {"halo/restart", "spring/restart"})
@ApiOperation("Restarts halo server") @ApiOperation("Restarts halo server")
@DisableOnCondition @DisableOnCondition
@Deprecated
public void restartApplication() { public void restartApplication() {
Application.restart(); throw new BadRequestException("此前的重启方案存在性能问题,故暂不支持重启功能!");
} }
@GetMapping(value = "halo/logfile") @GetMapping(value = "halo/logfile")