mirror of https://github.com/halo-dev/halo
commit
3f4843a63d
|
@ -2,6 +2,7 @@ package run.halo.app.config;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||||
|
@ -29,6 +30,7 @@ import run.halo.app.utils.HttpClientUtils;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStoreException;
|
import java.security.KeyStoreException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Halo configuration.
|
* Halo configuration.
|
||||||
|
@ -40,7 +42,8 @@ import java.security.NoSuchAlgorithmException;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class HaloConfiguration {
|
public class HaloConfiguration {
|
||||||
|
|
||||||
private final static int TIMEOUT = 5000;
|
@Autowired
|
||||||
|
HaloProperties haloProperties;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
|
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
|
||||||
|
@ -51,7 +54,8 @@ public class HaloConfiguration {
|
||||||
@Bean
|
@Bean
|
||||||
public RestTemplate httpsRestTemplate(RestTemplateBuilder builder) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
public RestTemplate httpsRestTemplate(RestTemplateBuilder builder) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||||
RestTemplate httpsRestTemplate = builder.build();
|
RestTemplate httpsRestTemplate = builder.build();
|
||||||
httpsRestTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(HttpClientUtils.createHttpsClient(TIMEOUT)));
|
httpsRestTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(HttpClientUtils.createHttpsClient(
|
||||||
|
(int) haloProperties.getDownloadTimeout().toMillis())));
|
||||||
return httpsRestTemplate;
|
return httpsRestTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,6 +60,11 @@ public class HaloProperties {
|
||||||
*/
|
*/
|
||||||
private String backupUrlPrefix = "/backup";
|
private String backupUrlPrefix = "/backup";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download Timeout.
|
||||||
|
*/
|
||||||
|
private Duration downloadTimeout = Duration.ofSeconds(30);
|
||||||
|
|
||||||
public HaloProperties() throws IOException {
|
public HaloProperties() throws IOException {
|
||||||
// Create work directory if not exist
|
// Create work directory if not exist
|
||||||
Files.createDirectories(Paths.get(workDir));
|
Files.createDirectories(Paths.get(workDir));
|
||||||
|
|
|
@ -46,4 +46,7 @@ logging:
|
||||||
level:
|
level:
|
||||||
run.halo.app: INFO
|
run.halo.app: INFO
|
||||||
file:
|
file:
|
||||||
path: ${user.home}/.halo/logs
|
path: ${user.home}/.halo/logs
|
||||||
|
|
||||||
|
halo:
|
||||||
|
download-timeout: 5m
|
Loading…
Reference in New Issue