mirror of https://github.com/halo-dev/halo
parent
236b3c418f
commit
ac8b43a30e
|
@ -6,7 +6,6 @@ import org.springframework.http.HttpStatus;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
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;
|
||||
|
@ -114,28 +113,6 @@ public class AdminController {
|
|||
adminService.updateAdminAssets();
|
||||
}
|
||||
|
||||
@GetMapping("spring/application.yaml")
|
||||
@ApiOperation("Gets application config content")
|
||||
@DisableOnCondition
|
||||
public BaseResponse<String> getSpringApplicationConfig() {
|
||||
return BaseResponse.ok(HttpStatus.OK.getReasonPhrase(), adminService.getApplicationConfig());
|
||||
}
|
||||
|
||||
@PutMapping("spring/application.yaml")
|
||||
@ApiOperation("Updates application config content")
|
||||
@DisableOnCondition
|
||||
public void updateSpringApplicationConfig(@RequestParam(name = "content") String content) {
|
||||
adminService.updateApplicationConfig(content);
|
||||
}
|
||||
|
||||
@PostMapping(value = {"halo/restart", "spring/restart"})
|
||||
@ApiOperation("Restarts halo server")
|
||||
@DisableOnCondition
|
||||
@Deprecated
|
||||
public void restartApplication() {
|
||||
throw new BadRequestException("此前的重启方案存在性能问题,故暂不支持重启功能!");
|
||||
}
|
||||
|
||||
@GetMapping(value = "halo/logfile")
|
||||
@ApiOperation("Gets halo log file content")
|
||||
@DisableOnCondition
|
||||
|
|
|
@ -25,8 +25,6 @@ public interface AdminService {
|
|||
|
||||
int REFRESH_TOKEN_EXPIRED_DAYS = 30;
|
||||
|
||||
String APPLICATION_CONFIG_NAME = "application.yaml";
|
||||
|
||||
String LOG_PATH = "logs/spring.log";
|
||||
|
||||
/**
|
||||
|
@ -97,20 +95,6 @@ public interface AdminService {
|
|||
*/
|
||||
void updateAdminAssets();
|
||||
|
||||
/**
|
||||
* Get application.yaml content.
|
||||
*
|
||||
* @return application.yaml content
|
||||
*/
|
||||
String getApplicationConfig();
|
||||
|
||||
/**
|
||||
* Save application.yaml content.
|
||||
*
|
||||
* @param content new content
|
||||
*/
|
||||
void updateApplicationConfig(@NonNull String content);
|
||||
|
||||
/**
|
||||
* Get halo logs content.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package run.halo.app.service.impl;
|
||||
|
||||
import cn.hutool.core.io.file.FileReader;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
@ -45,7 +44,6 @@ import java.io.IOException;
|
|||
import java.io.RandomAccessFile;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
|
@ -460,28 +458,6 @@ public class AdminServiceImpl implements AdminService {
|
|||
return token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getApplicationConfig() {
|
||||
File file = new File(haloProperties.getWorkDir(), APPLICATION_CONFIG_NAME);
|
||||
if (!file.exists()) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
FileReader reader = new FileReader(file);
|
||||
return reader.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateApplicationConfig(@NonNull String content) {
|
||||
Assert.notNull(content, "Content must not be null");
|
||||
|
||||
Path path = Paths.get(haloProperties.getWorkDir(), APPLICATION_CONFIG_NAME);
|
||||
try {
|
||||
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException e) {
|
||||
throw new ServiceException("保存配置文件失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLogFiles(@NonNull Long lines) {
|
||||
Assert.notNull(lines, "Lines must not be null");
|
||||
|
|
Loading…
Reference in New Issue