Skip to content

Commit

Permalink
Remove restart feature (halo-dev#917)
Browse files Browse the repository at this point in the history
* Ignore application-local file

* Remove restart feature
  • Loading branch information
JohnNiang authored Jun 15, 2020
1 parent 658f0a2 commit aee79ef
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
17 changes: 11 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -63,4 +63,9 @@ nbdist/
*.rar

### VSCode
.vscode
.vscode

### Local file
application-local.yml
application-local.yaml
application-local.properties
21 changes: 1 addition & 20 deletions src/main/java/run/halo/app/Application.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,29 +19,12 @@
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
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;
Expand Down Expand Up @@ -131,8 +131,9 @@ public void updateSpringApplicationConfig(@RequestParam(name = "content") String
@PostMapping(value = {"halo/restart", "spring/restart"})
@ApiOperation("Restarts halo server")
@DisableOnCondition
@Deprecated
public void restartApplication() {
Application.restart();
throw new BadRequestException("此前的重启方案存在性能问题,故暂不支持重启功能!");
}

@GetMapping(value = "halo/logfile")
Expand Down

0 comments on commit aee79ef

Please sign in to comment.