♻️ 重构代码。 gateway 降级获取原请求 ,docker-compose优化,日志优化

This commit is contained in:
冷冷 committed 2018-10-29 20:40:15 +08:00
1 parent e6723861e8
commit 02846103cd
5 files changed
+12 -40

No files matched your search

-35
View File
@@ -5,14 +5,12 @@ services:
ports:
- 2181:2181
restart: always
container_name: pigx-zookeeper
pigx-redis:
image: redis:4.0.10
ports:
- 6379:6379
restart: always
container_name: pigx-redis
pigx-eureka:
build:
@@ -21,88 +19,56 @@ services:
restart: always
ports:
- 1025:1025
container_name: pigx-eureka
pigx-config:
links:
- pigx-eureka
build:
context: ./
dockerfile: ./pigx-config/Dockerfile
restart: always
container_name: pigx-config
pigx-gateway:
links:
- pigx-eureka
- pigx-redis
build:
context: ./
dockerfile: ./pigx-gateway/Dockerfile
restart: always
ports:
- 9999:9999
container_name: pigx-gateway
pigx-auth:
links:
- pigx-eureka
- pigx-redis
build:
context: ./
dockerfile: ./pigx-auth/Dockerfile
restart: always
container_name: pigx-auth
pigx-upms:
links:
- pigx-eureka
- pigx-redis
- pigx-gateway
build:
context: ./
dockerfile: ./pigx-upms/pigx-upms-biz/Dockerfile
restart: always
container_name: pigx-upms
pigx-monitor:
links:
- pigx-eureka
- pigx-redis
build:
context: ./
dockerfile: ./pigx-visual/pigx-monitor/Dockerfile
restart: always
ports:
- 5001:5001
container_name: pigx-monitor
pigx-daemon:
links:
- pigx-eureka
- pigx-redis
build:
context: ./
dockerfile: ./pigx-visual/pigx-daemon/Dockerfile
restart: always
ports:
- 5002:5002
container_name: pigx-daemon
pigx-codegen:
links:
- pigx-eureka
- pigx-redis
build:
context: ./
dockerfile: ./pigx-visual/pigx-codegen/Dockerfile
restart: always
container_name: pigx-codegen
pigx-tx-manager:
links:
- pigx-eureka
- pigx-redis
build:
context: ./
dockerfile: ./pigx-visual/pigx-tx-manager/Dockerfile
@@ -110,4 +76,3 @@ services:
ports:
- 5004:5004
- 9998:9998
container_name: pigx-tx-manager
@@ -21,7 +21,7 @@
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
@@ -21,7 +21,7 @@
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
@@ -34,7 +34,7 @@
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
@@ -21,7 +21,7 @@
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
@@ -27,6 +27,10 @@ import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import java.util.Optional;
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR;
/**
* @author lengleng
* @date 2018/7/5
@@ -37,7 +41,10 @@ import reactor.core.publisher.Mono;
public class HystrixFallbackHandler implements HandlerFunction<ServerResponse> {
@Override
public Mono<ServerResponse> handle(ServerRequest serverRequest) {
log.error("网关执行请求:{}失败,hystrix服务降级处理", serverRequest.uri());
Optional<Object> originalUris = serverRequest.attribute(GATEWAY_ORIGINAL_REQUEST_URL_ATTR);
originalUris.ifPresent(originalUri -> log.error("网关执行请求:{}失败,hystrix服务降级处理", originalUri));
return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
.contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("服务异常"));
}