Quellcode durchsuchen

添加服务检测服务

chenweida vor 7 Jahren
Ursprung
Commit
484947af89

+ 59 - 0
server/svr-admin-server/pom.xml

@ -0,0 +1,59 @@
<?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>
        <groupId>com.yihu.jw</groupId>
        <artifactId>svr-lib-parent-pom</artifactId>
        <version>1.0.0</version>
        <relativePath>../../svr-lib-parent-pom/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>svr-admin-server</artifactId>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator-docs</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <!--服务器监监听-->
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-server</artifactId>
        </dependency>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-server-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zuul</artifactId>
        </dependency>
        <dependency>
            <groupId>com.netflix.servo</groupId>
            <artifactId>servo-core</artifactId>
        </dependency>
    </dependencies>
</project>

+ 4 - 0
server/svr-admin-server/readme.MD

@ -0,0 +1,4 @@
监测服务器
官网地址
http://codecentric.github.io/spring-boot-admin/1.5.3/#_reminder_notifications

+ 18 - 0
server/svr-admin-server/src/main/java/com.yihu.admin/AdminServer.java

@ -0,0 +1,18 @@
package com.yihu.admin;
import de.codecentric.boot.admin.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Configuration;
/**
 * Created by chenweida on 2017/8/15.
 */
@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class AdminServer {
    public static void main(String[] args) {
        SpringApplication.run(AdminServer.class, args);
    }
}

+ 37 - 0
server/svr-admin-server/src/main/resources/application.yml

@ -0,0 +1,37 @@
server:
  port: 8082
spring:
  application:
    name: svr-admin-server
  mail:
    host: smtp.qq.com
    port: 465
    username: 1501877145@qq.com
    protocol: smtp
    password: uihqhvqtrnkwhdhf #QQ的授权码
    properties:
      mail:
        smtp:
          auth: true
          socketFactory:
           class: javax.net.ssl.SSLSocketFactory
          starttls: true
          required: true
  boot:
    admin:
      url: http://localhost:${server.port}
      notify:
        mail:
          to: 494679975@qq.com
          from: 1501877145@qq.com
  jackson:
    serialization:
      indent_output: true
management:
  security:
    enabled: false

+ 27 - 0
server/svr-admin-server/src/main/resources/bootstrap.yml

@ -0,0 +1,27 @@
##优先读取 boostarap配置 然后在读取application。yml的配置
spring:
  #从发现服务里面取配置服务的信息
  cloud:
    config:
      username: jw
      password: jkzl
      failFast: true ##启动快速失败 即链接不到配置服务就启动失败
      discovery:
        enabled: true ##使用发现服务
        service-id: svr-configurations ##配置服务的名字
##发现服务的地址
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761//eureka/
  instance:
    #eurika使用IP不使用host
    prefer-ip-address: true
    #定制化在eurika中显示的名称
    ##instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}
    instance-id: ${spring.cloud.client.ipAddress}:${server.port}

+ 4 - 0
server/svr-admin-server/src/main/resources/logback.xml

@ -0,0 +1,4 @@
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>
    <jmxConfigurator/>
</configuration>

+ 3 - 1
server/svr-configuration/src/main/resources/application.yml

@ -18,7 +18,9 @@ eureka:
    ##instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}
    instance-id: ${spring.cloud.client.ipAddress}:${server.port}
management:
  security:
    enabled: false
---

+ 4 - 1
server/svr-configuration/src/main/resources/bootstrap.yml

@ -4,6 +4,8 @@ spring:
  jmx:
    default-domain: ${spring.application.name}
security:
  user:
    name: jw
@ -19,7 +21,8 @@ eureka:
    #定制化在eurika中显示的名称
    ##instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}
    instance-id: ${spring.cloud.client.ipAddress}:${server.port}
    appname: svr-configurations
    health-check-url-path: /health

+ 12 - 1
svr-lib-parent-pom/pom.xml

@ -81,7 +81,7 @@
        <version.joda-time>2.8.2</version.joda-time>
        <version.solr>5.5.1</version.solr>
        <version.fastdfs>1.25</version.fastdfs>
        <version.spring-boot-admin>1.5.7</version.spring-boot-admin>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <asciidoctor.maven.plugin.version>1.5.5</asciidoctor.maven.plugin.version>
@ -91,6 +91,17 @@
    <!--dependencyManagement作用子配置不写版本默认继承父配置-->
    <dependencyManagement>
        <dependencies>
            <!--服务器监监听-->
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-server</artifactId>
                <version>${version.spring-boot-admin}</version>
            </dependency>
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-server-ui</artifactId>
                <version>${version.spring-boot-admin}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>