SaaS平台开发实战(八):multienty-Admin服务状态监听

目录

导读

修改multienty-admin配置

修改saasdemo项目配置

修改nacos配置

修改multienty.yml配置

新增multienty-admin-dev.yml配置

测试


导读

我们在开发中需要随时监听服务的状态,以便我们精确查找问题,包括进程、线程、垃圾回收、内存等等,在运营期间我们不可能随时盯着服务器,在服务发生异常崩溃时自动邮件提醒也是非常必要的。在Multienty项目的multienty-admin模块既可,其实multienty-admin就是Spring Boot Admin的封装,让我们可以更简单的使用它。

在使用之前请先拉取Multienty最新代码

https://github.com/kutasms/multienty

或者

https://gitee.com/kutasms/multienty

同样的,您可以从下面的地址拉取本系列demo源代码

https://github.com/kutasms/saas-demo

或者

https://gitee.com/kutasms/saas-demo

修改multienty-admin配置

修改multienty-admin的bootstrap.yml文件

server:
  port: 9986
logging:
  config: classpath:logback-spring.xml
spring:
  application:
    name: multienty-admin
  cloud:
    nacos:
      discovery:
        # 以下内容根据实际情况配置
        server-addr: nacos.xxxx.cn:xxxxx
        namespace: xxxx-xxx-xxx-xxxxx
        username: xxxx
        password: xxxx
        metadata:
          user.name: ${spring.security.user.name}
          user.password: ${spring.security.user.password}
      config:
        server-addr: ${spring.cloud.nacos.discovery.server-addr}
        namespace: ${spring.cloud.nacos.discovery.namespace}
        username: ${spring.cloud.nacos.discovery.username}
        password: ${spring.cloud.nacos.discovery.password}
        file-extension: yml
        extension-configs[0]:
          data-id: multienty.yml
          group: DEFAULT_GROUP
          refresh: true

然后启动multienty-admin(您也可以修改server.port)

修改saasdemo项目配置

saasdemo-master, saasdemo-order, saasdemo-user 三个子模块的bootstrap.yml配置文件增加

spring.cloud.nacos.discovery.metadata节点,如下:

spring:
  application:
    name: saasdemo-master
  cloud:
    nacos:
      discovery:
        server-addr: nacos.xxxx.cn:xxxx
        namespace: xxxxx-xxx-xxx-xxxxx
        username: xxxx
        password: xxxx
        metadata:
          user.name: ${spring.security.user.name}
          user.password: ${spring.security.user.password}

修改nacos配置

修改multienty.yml配置

增加spring.security、spring.boot.admin和management节点

spring:    
    security:
        user:
            # 这里可以设置成您自己的用户名和密码
            name: "admin"
            password: "admin123"
    boot:
        admin:
            discovery:
                enabled: true
            client:
                enabled: true
                url: http://localhost:9986
                username: ${spring.security.user.name}
                password: ${spring.security.user.password}
                instance:
                    name: ${spring.application.name}
                    metadata:
                        user.name: ${spring.security.user.name}
                        user.password: ${spring.security.user.password}

management:
    health:
        redis:
            enabled: false
        sentinel:
            enabled: false
        ldap:
            enabled: false
    endpoints:
        web:
            exposure:
                include: "*"
    endpoint:
        health:
            show-details: always

新增multienty-admin-dev.yml配置

spring:
  boot:
    admin:
      notify:
        mail:
          to: xxx@163.com
          from: xxx@qq.com
  mail:
    default-encoding: UTF-8
    # 邮件服务器
    host: smtp.qq.com
    # 用户名
    username: "xxxx@qq.com"
    # 注意这里的密码要用授权码
    password: "xxxxxx"
    properties:
      mail:
        debug: false
        smtp:
          port: 465
          auth: true
          ssl:
            enable: true
            socket-factory: sf

测试

启动saasdemo-master、saasdemo-user、saasdemo-order三个子模块

访问localhost:9986

然后我们可以看Email通知

  • 24
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Multienty

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值