7 changed files with 175 additions and 0 deletions
@ -0,0 +1,11 @@ |
|||||
|
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 ./lb-test.jar |
||||
|
|
||||
|
EXPOSE 9999 |
||||
|
|
||||
|
ENTRYPOINT ["sh", "-c", "$RUN_INSTRUCT"] |
@ -0,0 +1,18 @@ |
|||||
|
version: "3.7" |
||||
|
services: |
||||
|
lb-test-server: |
||||
|
container_name: lb-test-server-dev |
||||
|
image: 192.168.1.130:10080/epmet-cloud-dev/lb-test-server:version_placeholder |
||||
|
ports: |
||||
|
- "9999:9999" |
||||
|
network_mode: host # 不会创建新的网络 |
||||
|
volumes: |
||||
|
- "/opt/epmet-cloud-logs/dev:/logs" |
||||
|
environment: |
||||
|
RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./lb-test.jar" |
||||
|
restart: "unless-stopped" |
||||
|
deploy: |
||||
|
resources: |
||||
|
limits: |
||||
|
cpus: '0.1' |
||||
|
memory: 300M |
@ -0,0 +1,47 @@ |
|||||
|
<?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> |
||||
|
</dependencies> |
||||
|
</project> |
@ -0,0 +1,11 @@ |
|||||
|
package com.epmet.lbtest; |
||||
|
|
||||
|
import org.springframework.boot.SpringApplication; |
||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
|
||||
|
@SpringBootApplication |
||||
|
public class LoadBalancerApp { |
||||
|
public static void main(String[] args) { |
||||
|
SpringApplication.run(LoadBalancerApp.class, args); |
||||
|
} |
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package com.epmet.lbtest.controller; |
||||
|
|
||||
|
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; |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("lb") |
||||
|
public class LbController { |
||||
|
|
||||
|
@GetMapping("test") |
||||
|
public String test(HttpServletRequest request) { |
||||
|
String localAddr = request.getServerName(); |
||||
|
return localAddr; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,68 @@ |
|||||
|
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 |
||||
|
cloud: |
||||
|
nacos: |
||||
|
discovery: |
||||
|
server-addr: 192.168.1.130:8848 |
||||
|
#nacos的命名空间ID,默认是public |
||||
|
namespace: 6ceab336-d004-4acf-89c6-e121d06f4988 |
||||
|
#不把自己注册到注册中心的地址 |
||||
|
register-enabled: false |
||||
|
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 |
Loading…
Reference in new issue