forked from luyan/epmet-cloud-lingshan
9 changed files with 0 additions and 403 deletions
@ -1,11 +0,0 @@ |
|||||
FROM java:8 |
|
||||
|
|
||||
RUN export LANG="zh_CN.UTF-8" |
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime |
|
||||
RUN echo 'Asia/Shanghai' > /etc/timezone |
|
||||
|
|
||||
COPY ./target/*.jar ./epmet-lb-test.jar |
|
||||
|
|
||||
EXPOSE 9999 |
|
||||
|
|
||||
ENTRYPOINT ["sh", "-c", "exec $RUN_INSTRUCT"] |
|
@ -1,18 +0,0 @@ |
|||||
version: "3.7" |
|
||||
services: |
|
||||
epmet-lb-test: |
|
||||
container_name: epmet-lb-test-dev |
|
||||
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-lb-test:version_placeholder |
|
||||
ports: |
|
||||
- "9999:9999" |
|
||||
network_mode: host # 不会创建新的网络 |
|
||||
volumes: |
|
||||
- "/opt/epmet-cloud-logs/dev:/logs" |
|
||||
environment: |
|
||||
RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./epmet-lb-test.jar" |
|
||||
restart: "unless-stopped" |
|
||||
deploy: |
|
||||
resources: |
|
||||
limits: |
|
||||
cpus: '0.1' |
|
||||
memory: 300M |
|
@ -1,66 +0,0 @@ |
|||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
||||
<parent> |
|
||||
<artifactId>epmet-cloud</artifactId> |
|
||||
<groupId>com.epmet</groupId> |
|
||||
<version>2.0.0</version> |
|
||||
</parent> |
|
||||
<modelVersion>4.0.0</modelVersion> |
|
||||
|
|
||||
<artifactId>epmet-lb-test</artifactId> |
|
||||
|
|
||||
<dependencies> |
|
||||
<!--<dependency> |
|
||||
<groupId>com.epmet</groupId> |
|
||||
<artifactId>epmet-commons-tools</artifactId> |
|
||||
<version>2.0.0</version> |
|
||||
</dependency>--> |
|
||||
<dependency> |
|
||||
<groupId>org.springframework.boot</groupId> |
|
||||
<artifactId>spring-boot-starter-web</artifactId> |
|
||||
</dependency> |
|
||||
<dependency> |
|
||||
<groupId>org.springframework</groupId> |
|
||||
<artifactId>spring-context-support</artifactId> |
|
||||
</dependency> |
|
||||
<dependency> |
|
||||
<groupId>org.springframework.boot</groupId> |
|
||||
<artifactId>spring-boot-starter-actuator</artifactId> |
|
||||
</dependency> |
|
||||
<dependency> |
|
||||
<groupId>com.alibaba.cloud</groupId> |
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
|
||||
</dependency> |
|
||||
<dependency> |
|
||||
<groupId>com.alibaba.cloud</groupId> |
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
|
||||
</dependency> |
|
||||
<!-- 替换Feign原生httpclient --> |
|
||||
<dependency> |
|
||||
<groupId>io.github.openfeign</groupId> |
|
||||
<artifactId>feign-httpclient</artifactId> |
|
||||
<version>10.3.0</version> |
|
||||
</dependency> |
|
||||
<dependency> |
|
||||
<groupId>org.springframework.cloud</groupId> |
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId> |
|
||||
</dependency> |
|
||||
<!--<dependency> |
|
||||
<groupId>com.epmet</groupId> |
|
||||
<artifactId>epmet-commons-tools</artifactId> |
|
||||
<version>2.0.0</version> |
|
||||
</dependency>--> |
|
||||
</dependencies> |
|
||||
|
|
||||
<build> |
|
||||
<plugins> |
|
||||
<plugin> |
|
||||
<groupId>org.springframework.boot</groupId> |
|
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
|
||||
<!--<version>2.1.11.RELEASE</version>--> |
|
||||
</plugin> |
|
||||
</plugins> |
|
||||
</build> |
|
||||
</project> |
|
@ -1,15 +0,0 @@ |
|||||
package com.epmet.lbtest; |
|
||||
|
|
||||
import org.springframework.boot.SpringApplication; |
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients; |
|
||||
|
|
||||
@EnableDiscoveryClient |
|
||||
@EnableFeignClients |
|
||||
@SpringBootApplication |
|
||||
public class LoadBalancerApp { |
|
||||
public static void main(String[] args) { |
|
||||
SpringApplication.run(LoadBalancerApp.class, args); |
|
||||
} |
|
||||
} |
|
@ -1,29 +0,0 @@ |
|||||
package com.epmet.lbtest.controller; |
|
||||
|
|
||||
import com.epmet.lbtest.feign.TestCallFeignClient; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.cloud.commons.util.InetUtils; |
|
||||
import org.springframework.web.bind.annotation.GetMapping; |
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
|
||||
import org.springframework.web.bind.annotation.RestController; |
|
||||
|
|
||||
import javax.servlet.http.HttpServletRequest; |
|
||||
import java.net.Inet4Address; |
|
||||
import java.net.InetAddress; |
|
||||
import java.net.UnknownHostException; |
|
||||
|
|
||||
@RestController |
|
||||
@RequestMapping("lb") |
|
||||
public class LbController { |
|
||||
|
|
||||
@Autowired |
|
||||
private InetUtils inetUtils; |
|
||||
|
|
||||
@Autowired |
|
||||
private TestCallFeignClient testCallFeignClient; |
|
||||
|
|
||||
@GetMapping("test") |
|
||||
public String test() { |
|
||||
return inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); |
|
||||
} |
|
||||
} |
|
@ -1,10 +0,0 @@ |
|||||
package com.epmet.lbtest.feign; |
|
||||
|
|
||||
import org.springframework.cloud.openfeign.FeignClient; |
|
||||
import org.springframework.web.bind.annotation.GetMapping; |
|
||||
|
|
||||
@FeignClient(name = "lb-test", fallback = TestCallFeignClientFallback.class) |
|
||||
public interface TestCallFeignClient { |
|
||||
@GetMapping("/lbtest/lb/test") |
|
||||
String test(); |
|
||||
} |
|
@ -1,11 +0,0 @@ |
|||||
package com.epmet.lbtest.feign; |
|
||||
|
|
||||
import org.springframework.stereotype.Component; |
|
||||
|
|
||||
@Component |
|
||||
public class TestCallFeignClientFallback implements TestCallFeignClient { |
|
||||
@Override |
|
||||
public String test() { |
|
||||
return "请求出错"; |
|
||||
} |
|
||||
} |
|
@ -1,74 +0,0 @@ |
|||||
server: |
|
||||
port: 9999 |
|
||||
servlet: |
|
||||
context-path: /lbtest |
|
||||
|
|
||||
spring: |
|
||||
main: |
|
||||
allow-bean-definition-overriding: true |
|
||||
application: |
|
||||
name: lb-test |
|
||||
#环境 dev|test|prod |
|
||||
profiles: |
|
||||
active: local |
|
||||
jackson: |
|
||||
time-zone: GMT+8 |
|
||||
date-format: yyyy-MM-dd HH:mm:ss |
|
||||
redis: |
|
||||
database: 0 |
|
||||
host: 192.168.1.130 |
|
||||
port: 6379 |
|
||||
password: 123456 |
|
||||
timeout: 30s |
|
||||
cloud: |
|
||||
nacos: |
|
||||
discovery: |
|
||||
server-addr: 192.168.1.130:8848 |
|
||||
#nacos的命名空间ID,默认是public |
|
||||
namespace: 6ceab336-d004-4acf-89c6-e121d06f4988 |
|
||||
#不把自己注册到注册中心的地址 |
|
||||
register-enabled: true |
|
||||
ip: "" |
|
||||
config: |
|
||||
enabled: false |
|
||||
server-addr: 192.168.1.130:8848 |
|
||||
namespace: "" |
|
||||
group: "" |
|
||||
file-extension: yaml |
|
||||
#指定共享配置,且支持动态刷新 |
|
||||
|
|
||||
management: |
|
||||
endpoints: |
|
||||
web: |
|
||||
exposure: |
|
||||
include: "*" |
|
||||
endpoint: |
|
||||
health: |
|
||||
show-details: ALWAYS |
|
||||
|
|
||||
feign: |
|
||||
hystrix: |
|
||||
enabled: true |
|
||||
client: |
|
||||
config: |
|
||||
default: |
|
||||
loggerLevel: BASIC |
|
||||
httpclient: |
|
||||
enabled: true |
|
||||
|
|
||||
hystrix: |
|
||||
command: |
|
||||
default: |
|
||||
execution: |
|
||||
isolation: |
|
||||
thread: |
|
||||
timeoutInMilliseconds: 60000 #缺省为1000 |
|
||||
|
|
||||
ribbon: |
|
||||
ReadTimeout: 300000 |
|
||||
ConnectTimeout: 300000 |
|
||||
|
|
||||
#feign 日志需要该配置 |
|
||||
logging: |
|
||||
level: |
|
||||
com.epmet: debug |
|
@ -1,169 +0,0 @@ |
|||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||
<configuration> |
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml"/> |
|
||||
|
|
||||
<property name="log.path" value="logs/lb-test"/> |
|
||||
|
|
||||
<springProperty scope="context" name="appname" source="spring.application.name"/> |
|
||||
<springProperty scope="context" name="webHook" source="dingTalk.robot.webHook"/> |
|
||||
<springProperty scope="context" name="secret" source="dingTalk.robot.secret"/> |
|
||||
|
|
||||
<!-- 日志上下文名称 --> |
|
||||
<contextName>${appname}</contextName> |
|
||||
|
|
||||
<!-- 彩色日志格式 --> |
|
||||
<property name="CONSOLE_LOG_PATTERN" |
|
||||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> |
|
||||
|
|
||||
<!--1. 输出到控制台--> |
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> |
|
||||
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息--> |
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
|
||||
<level>debug</level> |
|
||||
</filter> |
|
||||
<encoder> |
|
||||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern> |
|
||||
<!-- 设置字符集 --> |
|
||||
<charset>UTF-8</charset> |
|
||||
</encoder> |
|
||||
</appender> |
|
||||
|
|
||||
<!--2. 输出到文档--> |
|
||||
<!-- 2.1 level为 DEBUG 日志,时间滚动输出 --> |
|
||||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|
||||
<!-- 正在记录的日志文档的路径及文档名 --> |
|
||||
<file>${log.path}/debug.log</file> |
|
||||
<!--日志文档输出格式--> |
|
||||
<encoder> |
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern> |
|
||||
<charset>UTF-8</charset> <!-- 设置字符集 --> |
|
||||
</encoder> |
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|
||||
<!-- 日志归档 --> |
|
||||
<fileNamePattern>${log.path}/debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|
||||
<maxFileSize>100MB</maxFileSize> |
|
||||
</timeBasedFileNamingAndTriggeringPolicy> |
|
||||
<!--日志文档保留天数--> |
|
||||
<maxHistory>15</maxHistory> |
|
||||
</rollingPolicy> |
|
||||
<!-- 此日志文档只记录debug级别的 --> |
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|
||||
<level>debug</level> |
|
||||
<onMatch>ACCEPT</onMatch> |
|
||||
<onMismatch>DENY</onMismatch> |
|
||||
</filter> |
|
||||
</appender> |
|
||||
|
|
||||
<!-- 2.2 level为 INFO 日志,时间滚动输出 --> |
|
||||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|
||||
<!-- 正在记录的日志文档的路径及文档名 --> |
|
||||
<file>${log.path}/info.log</file> |
|
||||
<!--日志文档输出格式--> |
|
||||
<encoder> |
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern> |
|
||||
<charset>UTF-8</charset> |
|
||||
</encoder> |
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|
||||
<!-- 每天日志归档路径以及格式 --> |
|
||||
<fileNamePattern>${log.path}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|
||||
<maxFileSize>100MB</maxFileSize> |
|
||||
</timeBasedFileNamingAndTriggeringPolicy> |
|
||||
<!--日志文档保留天数--> |
|
||||
<maxHistory>15</maxHistory> |
|
||||
</rollingPolicy> |
|
||||
<!-- 此日志文档只记录info级别的 --> |
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|
||||
<level>info</level> |
|
||||
<onMatch>ACCEPT</onMatch> |
|
||||
<onMismatch>DENY</onMismatch> |
|
||||
</filter> |
|
||||
</appender> |
|
||||
|
|
||||
<!-- 2.3 level为 WARN 日志,时间滚动输出 --> |
|
||||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|
||||
<!-- 正在记录的日志文档的路径及文档名 --> |
|
||||
<file>${log.path}/warn.log</file> |
|
||||
<!--日志文档输出格式--> |
|
||||
<encoder> |
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern> |
|
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|
||||
</encoder> |
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|
||||
<fileNamePattern>${log.path}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|
||||
<maxFileSize>100MB</maxFileSize> |
|
||||
</timeBasedFileNamingAndTriggeringPolicy> |
|
||||
<!--日志文档保留天数--> |
|
||||
<maxHistory>15</maxHistory> |
|
||||
</rollingPolicy> |
|
||||
<!-- 此日志文档只记录warn级别的 --> |
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|
||||
<level>warn</level> |
|
||||
<onMatch>ACCEPT</onMatch> |
|
||||
<onMismatch>DENY</onMismatch> |
|
||||
</filter> |
|
||||
</appender> |
|
||||
|
|
||||
<!-- 2.4 level为 ERROR 日志,时间滚动输出 --> |
|
||||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|
||||
<!-- 正在记录的日志文档的路径及文档名 --> |
|
||||
<file>${log.path}/error.log</file> |
|
||||
<!--日志文档输出格式--> |
|
||||
<encoder> |
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern> |
|
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|
||||
</encoder> |
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|
||||
<fileNamePattern>${log.path}/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|
||||
<maxFileSize>100MB</maxFileSize> |
|
||||
</timeBasedFileNamingAndTriggeringPolicy> |
|
||||
<!--日志文档保留天数--> |
|
||||
<maxHistory>15</maxHistory> |
|
||||
</rollingPolicy> |
|
||||
<!-- 此日志文档只记录ERROR级别的 发送钉钉短信 --> |
|
||||
<filter class="com.epmet.commons.tools.filter.LogMsgSendFilter"> |
|
||||
<level>ERROR</level> |
|
||||
<onMatch>ACCEPT</onMatch> |
|
||||
<onMismatch>DENY</onMismatch> |
|
||||
<webHook>${webHook}</webHook> |
|
||||
<secret>${secret}</secret> |
|
||||
<appName>${appname}</appName> |
|
||||
</filter> |
|
||||
</appender> |
|
||||
|
|
||||
<!-- 开发、测试环境 --> |
|
||||
<springProfile name="dev,test,local"> |
|
||||
<logger name="org.springframework.web" level="INFO"/> |
|
||||
<logger name="org.springboot.sample" level="INFO"/> |
|
||||
<logger name="com.epmet.dao" level="INFO"/> |
|
||||
<logger name="com.epmet.dao" level="DEBUG"/> |
|
||||
<root level="INFO"> |
|
||||
<appender-ref ref="DEBUG_FILE"/> |
|
||||
<appender-ref ref="INFO_FILE"/> |
|
||||
<appender-ref ref="WARN_FILE"/> |
|
||||
<appender-ref ref="ERROR_FILE"/> |
|
||||
</root> |
|
||||
</springProfile> |
|
||||
|
|
||||
<!-- 生产环境 --> |
|
||||
<springProfile name="prod"> |
|
||||
<logger name="org.springframework.web" level="INFO"/> |
|
||||
<logger name="org.springboot.sample" level="INFO"/> |
|
||||
<logger name="com.epmet.dao" level="INFO"/> |
|
||||
<root level="INFO"> |
|
||||
<appender-ref ref="CONSOLE"/> |
|
||||
<appender-ref ref="DEBUG_FILE"/> |
|
||||
<appender-ref ref="INFO_FILE"/> |
|
||||
<appender-ref ref="WARN_FILE"/> |
|
||||
<appender-ref ref="ERROR_FILE"/> |
|
||||
</root> |
|
||||
</springProfile> |
|
||||
|
|
||||
</configuration> |
|
Loading…
Reference in new issue