katmore / healthsvc
健康Web服务
v1.0.3
2018-12-15 03:39 UTC
Requires
- php: >=7.2.1
Requires (Dev)
- guzzlehttp/guzzle: ~6.0
- php-di/phpdoc-reader: ^2.1
- phpunit/php-code-coverage: ^6.0
- phpunit/phpunit: ^7
This package is not auto-updated.
Last update: 2024-09-24 03:28:40 UTC
README
Healthsvc是一个具有RESTful API接口的系统健康状况服务。它可以独立使用,也可以集成到现有项目中。它旨在与DevOps工作流程、功能测试、监控软件等一起使用。
作为独立服务使用
-
下载healthsvc
git clone https://github.com/katmore/healthsvc.git
-
使用Composer更新
cd healthsvc composer update
-
使用
host-sanity-config.php
命令行工具打印可用的“主机健康”测试列表bin/host-sanity-config.php --print-bin-list
-
使用
host-sanity-config.php
命令行工具添加带有标签“free-space”的“主机健康”测试bin/host-sanity-config.php --bin free-space free-space-check /tmp
-
配置用于HTTP服务器的端点
-
仅限开发使用
- 启动
webservice
命令行工具
bin/webservice
- 启动
-
生产或开发
- 在现有的HTTP根目录中创建指向
healthsvc/web
目录的符号链接
ln -s /var/www/healthsvc/web /var/www/html/healthsvc
- --OR--
- 使用
healthsvc/web
目录作为HTTP根目录
# nginx example server { ... root /var/www/healthsvc/web; ... }
- 在现有的HTTP根目录中创建指向
-
-
测试
web/host-sanity.php
Web服务端点- 例如,使用
curl
命令行工具curl https://:8000/host-sanity.php
- 例如,使用
-
web/host-sanity.php
响应体示例,当测试处于“成功”状态时(200/OK响应代码){ "hostname": "my-host", "exec_exit_status": [], "health_status_time": "2018-12-11T21:51:36-08:00", "health_status_ttl": 0, "message": "total success", "health_info": { "free-space": { "stdout": [ "ok: '\/tmp' has 81% free disk space" ] } }, "health_success": [ "free-space" ], "health_warn": [], "health_failure": [] }
-
web/host-sanity.php
响应体示例,当一个或多个测试处于“失败”状态时(500/内部服务器错误响应代码){ "hostname": "my-host", "exec_exit_status": { "free-space": 3 }, "health_status_time": "2018-12-11T21:58:45-08:00", "health_status_ttl": 0, "message": "one or more failures", "health_info": [], "health_success": [], "health_warn": [], "health_failure": { "free-space": { "stdout": [ "'\/tmp' has only 10% free disk space (20% is minimum required)" ] } } }
在现有项目中使用
-
有关更多详细信息,请参阅PHP使用文档。
-
使用Composer将其添加到现有项目中。
composer require katmore/healthsvc
单元测试
docs/coverage.txt
:单元测试覆盖率报告phpunit.xml.dist
:PHPUnit配置文件tests/phpunit
:单元测试源代码
要执行单元测试,请在vendor/bin
目录中执行phpunit。
vendor/bin/phpunit
提供tests.sh
包装脚本以方便使用。
./tests.sh
法律
"Healthsvc"根据MIT许可证或GPLv3许可证的条款进行分发。
版权(c)2018-2019,Doug Bird。保留所有权利。