{"id":23087638,"url":"https://github.com/exp-codes/one-to-m-liveness","last_synced_at":"2025-04-03T16:45:38.838Z","repository":{"id":70890550,"uuid":"494845666","full_name":"EXP-Codes/one-to-m-liveness","owner":"EXP-Codes","description":"一对多探活器","archived":false,"fork":false,"pushed_at":"2023-01-16T18:07:15.000Z","size":81,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T05:27:38.975Z","etag":null,"topics":["liveness","programming"],"latest_commit_sha":null,"homepage":"http://localhost:8080/health/liveness","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EXP-Codes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://lyy289065406.github.io/sponsor/"]}},"created_at":"2022-05-21T17:06:05.000Z","updated_at":"2023-05-03T14:57:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"490b486b-611b-4a4f-b132-d60e4cd81850","html_url":"https://github.com/EXP-Codes/one-to-m-liveness","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fone-to-m-liveness","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fone-to-m-liveness/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fone-to-m-liveness/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fone-to-m-liveness/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EXP-Codes","download_url":"https://codeload.github.com/EXP-Codes/one-to-m-liveness/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247043220,"owners_count":20874084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["liveness","programming"],"created_at":"2024-12-16T19:59:26.404Z","updated_at":"2025-04-03T16:45:38.832Z","avatar_url":"https://github.com/EXP-Codes.png","language":"Java","funding_links":["https://lyy289065406.github.io/sponsor/"],"categories":[],"sub_categories":[],"readme":"# one-to-many liveness\n\n\u003e 一对多探活器\n------\n\n## 运行环境\n\n[![](https://img.shields.io/badge/JDK-1.8%2B-brightgreen.svg)](https://www.oracle.com/java/technologies/javase/javase8-archive-downloads.html) [![](https://img.shields.io/badge/SpringBoot-2.7.0-brightgreen.svg)](https://maven.apache.org/) [![](https://img.shields.io/badge/IDE-Idea-brightgreen.svg)](https://www.jetbrains.com/zh-cn/idea/) ![](https://img.shields.io/badge/Platform-windows|*nix-brightgreen.svg)\n\n\n## 简介\n\n适用于微服务等含有多个模块的应用做统一探活，主要作用是收敛探活的多个故障告警到产品本身。原理很简单：\n\n把其他需要探活的服务接口（目前只支持 HTTP 和 Socket）配置到这个项目，由它代理对各个服务发起探活检测，最后把各个服务的存活情况聚合返回。\n\n\n## 配置方法\n\n把需要做探活的服务接口配置到 [`application.yml`](./src/main/resources/application.yml) ，配置方法参考其中的 demo :\n\n```yml\n# 需要探活的服务列表（格式一）\ndetected-list:\n  remoteServices:\n    - name: \"exp\"\n      protocol: \"http\"\n      address: \"https://exp-blog.com\"\n    - name: \"qq\"\n      protocol: \"socket\"\n      address: \"127.0.0.1:65535\"\n\n# 需要探活的服务列表（格式二）\ndetected-list.remoteServices[2].name: \"baidu\"\ndetected-list.remoteServices[2].protocol: \"http\"\ndetected-list.remoteServices[2].address: \"https://www.baidu.com\"\ndetected-list.remoteServices[3].name: \"springboot\"\ndetected-list.remoteServices[3].protocol: \"socket\"\ndetected-list.remoteServices[3].address: \"127.0.0.1:8080\"\n```\n\n\n## 使用方法\n\n运行此项目后，访问 [http://localhost:8080/health/liveness](http://localhost:8080/health/liveness) 即可查看所有被测服务的结果：\n\n```json\n{\n  \"ok\": false,\n  \"total\": 4,\n  \"errorNum\": 1,\n  \"errorData\": [\n    {\n      \"name\": \"qq\",\n      \"protocol\": \"socket\",\n      \"address\": \"127.0.0.1:65535\",\n      \"statusCode\": -1,\n      \"statusDesc\": \"Detecte Error\"\n    }\n  ],\n  \"sussessData\": [\n    {\n      \"name\": \"exp\",\n      \"protocol\": \"http\",\n      \"address\": \"https://exp-blog.com\",\n      \"statusCode\": 200,\n      \"statusDesc\": \"\"\n    },\n    {\n      \"name\": \"baidu\",\n      \"protocol\": \"http\",\n      \"address\": \"https://www.baidu.com\",\n      \"statusCode\": 200,\n      \"statusDesc\": \"\"\n    },\n    {\n      \"name\": \"springboot\",\n      \"protocol\": \"socket\",\n      \"address\": \"127.0.0.1:8080\",\n      \"statusCode\": 0,\n      \"statusDesc\": \"\"\n    }\n  ]\n}\n```\n\n需注意，[http://localhost:8080/health/liveness](http://localhost:8080/health/liveness) 接口正常情况下只会有两种状态码：\n\n- `HTTP 200`： 所有的被测服务均正常\n- `HTTP 206`： 部分或所有的被测服务异常\n\n\u003e 其他状态码均表示 `/health/liveness` 接口本身的服务异常，但是自身探活建议用 `/health/self` 接口。\n\n\n## 容器化\n\n本项目以支持容器化，在项目根目录下运行以下脚本即可：\n\n1. [`bin/clean.sh`](./bin/clean.sh) 或 [`bin/clean.ps1`](./bin/clean.ps1)： 清理镜像\n2. [`bin/build.sh`](./bin/build.sh) 或 [`bin/clean.ps1`](./bin/build.ps1)： 构建镜像\n3. [`bin/deploy.sh`](./bin/deploy.sh) 或 [`bin/deploy.ps1`](./bin/deploy.ps1)： 发布镜像\n4. [`bin/run.sh`](./bin/run.sh) 或 [`bin/run.ps1`](./bin/run.ps1)： 运行容器\n5. [`bin/stop.sh`](./bin/stop.sh) 或 [`bin/stop.ps1`](./bin/stop.ps1)： 停止容器\n\n若需要在容器中修改 [`application.yml`](./res/apps/one-to-m-liveness/config/application.yml)， 只需把 `./res/apps/one-to-m-liveness/config/application.yml` 挂载出来修改即可。\n\n\u003e 最新镜像已发布到 docker hub : [`docker pull expm02/one-to-m-liveness:latest`](https://hub.docker.com/r/expm02/one-to-m-liveness)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexp-codes%2Fone-to-m-liveness","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexp-codes%2Fone-to-m-liveness","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexp-codes%2Fone-to-m-liveness/lists"}