美文网首页
8、hystrix-dashboard-10001

8、hystrix-dashboard-10001

作者: knock | 来源:发表于2020-07-13 02:10 被阅读0次

模块结构

image.png

模块代码

pom.xml

<?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>spring-cloud</artifactId>
        <groupId>com.yyd.cloud</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>hystrix-dashboard-10001</artifactId>

    <dependencies>
        <!-- hystrix监控页面依赖-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        </dependency>
    </dependencies>



    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!--指定打包方式 loader.path使用-->
                    <layout>ZIP</layout>
                    <!--去除在生产环境中不变的依赖,只包含业务代码-->
                    <includes>
                        <include>
                            <groupId>com.yyd.cloud</groupId>
                            <artifactId>*</artifactId>
                        </include>
                    </includes>
                </configuration>
            </plugin>

            <!--拷贝依赖jar到lib-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


            <!--拷贝资源文件 copy-resources, config固定 -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>src/main/resources</directory>
                                </resource>
                            </resources>
                            <outputDirectory>${project.build.directory}/config</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!--拷贝target下的jar到targets-->
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-lib-target</id>
                        <phase>package</phase>
                        <configuration>
                            <tasks>
                                <copy todir="../targets">
                                    <fileset dir="target">
                                        <include name="*.jar"/>
                                    </fileset>
                                </copy>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>

        <!-- 排除资源文件 -->
        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>**/*.yml</exclude>
                </excludes>
            </resource>
        </resources>

    </build>
</project>

DockerFile

# 基础 JRE 镜像
FROM registry.cn-hangzhou.aliyuncs.com/ydyan/cloud:v0.1
MAINTAINER 13270809619@163.com

WORKDIR /root/hystrix-dashboard-10001

ENV APP_HOME=/root/hystrix-dashboard-10001
ENV MAIN_JAR=hystrix-dashboard-10001-1.0-SNAPSHOT.jar
ENV JVMOPTIONS="-Xms128M -Xmx1G"
#声明容器端口
ENV EXPOSE_PORT=10001
ENV CONFIG_LABEL=master
ENV ENV_TYPE=dev

# 修改时区,使得容器时间为北京时间
RUN echo "Asia/Shanghai" > /etc/timezone

# 将所需项目文件复制进入容器中
ADD target/$MAIN_JAR $APP_HOME/
ADD target/lib/ $APP_HOME/lib/
ADD target/config/ $APP_HOME/config/

# 运行项目

CMD java $JVMOPTIONS -jar  -Dloader.path=$APP_HOME,$APP_HOME/lib -Dfile.encoding=UTF-8 $APP_HOME/$MAIN_JAR

EXPOSE $EXPOSE_PORT


#---docker服务---
#docker pull centos:7
#docker tag 37bb9c63c8b2 registry-vpc.cn-hangzhou.aliyuncs.com/acs/agent:0.7-dfb6816   镜像改名
#docker build -t yd-cloud:v0.1 .
#docker run -d -p 9001:9001 -p 9002:9002 yd-cloud:v0.1
#docker run -d -p 10001:8888(本机:容器) -name springboot(容器名称) -v /usr/local/bigdata/dockerlogs/:/usr/local/logs/ yd-cloud:v0.1
#docker ps -a (全部容器) |docker ps (运行中容器)
#docker exec -it 8b /bin/bash  (进入容器)
#docker logs -f -t --tail 500 容器名称/容器id 查看docker日志
#docker images 查看镜像
#docker kill 容器名称/容器id
#docker rm 容器名称/容器id
#docker rmi 镜像id
#docker image rm -f 镜像id

resources
application.yml

server:
  port: 10001

logback.xml

<configuration scanPeriod="10 seconds" debug="true">
    <!-- 彩色日志依赖的渲染类 -->
    <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
    <conversionRule conversionWord="wex"
                    converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
    <conversionRule conversionWord="wEx"
                    converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>

    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <encoder charset="UTF-8">
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} [%file : %line] - %msg%n</pattern>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- rollover daily 配置日志所生成的目录以及生成文件名的规则 -->
            <fileNamePattern>logs/dashboard-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy
                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <!-- 单个日志文件最大100MB -->
                <maxFileSize>100MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <!-- 日志文件保存15天 -->
            <maxHistory>15</maxHistory>
        </rollingPolicy>
        <prudent>false</prudent>
    </appender>

    <!-- 彩色日志格式 -->
    <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}}"/>
    <!-- Console 输出设置 -->
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
            <charset>utf8</charset>
        </encoder>
    </appender>

    <!--<springProfile name="dev,test,prod">-->
    <!--<root level="INFO">-->
    <!--<appender-ref ref="CONSOLE"/>-->
    <!--<appender-ref ref="FILE"/>-->
    <!--</root>-->
    <!--&lt;!&ndash;<logger name="com.yyd.mapper" level="DEBUG"/>&ndash;&gt;-->
    <!--</springProfile>-->

    <root level="INFO">
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="FILE"/>
    </root>

</configuration>

java

DashBoardApplication.java

package com.yyd.dashboard;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;

/***
 * @ClassName: DashBoardApplication
 * @Description: TODO
 * @author: yanyd
 * @Date: 7:23 2020/5/31
 * @version : V1.0
 */
@SpringBootApplication
@EnableHystrixDashboard    //开启
public class DashBoardApplication {

    //仪表盘url:http://localhost:10001/hystrix
    //被监听url:http://localhost:8004/actuator/hystrix.stream

    public static void main(String[] args) {
        SpringApplication.run(DashBoardApplication.class, args);
    }

}

相关文章

  • 8、hystrix-dashboard-10001

    模块结构 模块代码 pom.xml DockerFile resourcesapplication.yml log...

  • 8-8-8

    发-发-发 今天比较闲,备忘录看了一遍又一遍,发现没有什么具体的工作非得马上完成。 又不想看微博浪费时间,想来想去...

  • 8、8

    山重水复疑无路,柳暗花明又一村。人生有万千种可能,但是真的有一种成功,叫坚持到底!

  • 8/8

    今天有人问我,你的脾气一直都是这么好的吗?还是说你也看人的? 我笑笑说,你觉得呢? 虽然表面上,我波澜不惊,可我的...

  • 35年静脉曲张老烂腿案例

    【35年静脉曲张老烂腿案例】 1/8 2/8 3/8 4/8 5/8 6/8 7/8 8/8

  • 寒假计划安排表

    8:00 起床 8:00~8:10 洗漱 8:10~8:40 吃早饭 8:50~9:...

  • 作息时间表(家)

    上午 8:00起床 8:00~8:20洗漱,吃早饭 8:20~8:30看视频 8:30~8:50背单词 8:50~...

  • 2021-01-07

    脑洞大开智力PK 蓝白领(辑) 之一 5 1 5 5=24 8 8 8 8 8 8 8 8 =1000 在数字与数...

  • 24=8+8+8

    当表盘里的时针转了一圈以后,崭新的一天已经开始。实际上,每个人得生活方式是大相径庭的,8小时睡觉,8小时工作,每天...

  • 假期计划

    醒来 : 8:00 记单词: 8:00~8:30(半小时) 起床 : 8:30 洗漱 : 8:30~8:50 (二...

网友评论

      本文标题:8、hystrix-dashboard-10001

      本文链接:https://www.haomeiwen.com/subject/ycyocktx.html