nordsec/status-checker
最新稳定版本:2.1.1
Composer 安装命令:
composer require nordsec/status-checker
包简介
A library for implementing status checks
README 文档
README
Description
A library that tells you if any external service your app relies on is broken.
Extremely useful for:
- Creating a command that will show whether the app is ok after deployment
- Creating a status page for your system admins or monitoring software
Requirements
- PHP >=7.4 || >=8.0
Usage
CLI
- Install the library
composer require nordsec/status-checker
- Declare an instance for StatusCheckerService (preferably using a container), pass various status checkers that make sense for your project
$container[StatusCheckerService::class] = function (Container $container) { $configuration = $container['config']; return new StatusCheckerService([ new DatabaseChecker('database.default_connection', $configuration['database']['default']), new RabbitMqChecker('rabbitmq.amqp_server', $configuration['queue']['connection_nordvpn_core']), ]); };
- If needed, register the command with your application
$container[StatusCheckCommand::class] = function (Container $container) { return new StatusCheckCommand([ $container[StatusCheckerService::class], ]); }; $container[ConsoleApplication::class] = $container->extend( ConsoleApplication::class, function (ConsoleApplication $consoleApplication, Container $container) { $consoleApplication->add($container[StatusCheckCommand::class]); return $consoleApplication; } );
- Run the command
bin/console status:check
WEB
- Install the library
composer require nordsec/status-checker
- Declare an instance for StatusCheckerService (preferably using a container), pass various status checkers that make sense for your project
$container[StatusCheckerService::class] = function (Container $container) { $configuration = $container['config']; return new StatusCheckerService([ new DatabaseChecker('database.default_connection', $configuration['database']['default']), new RabbitMqChecker('rabbitmq.nordvpn_core', $configuration['queue']['connection_nordvpn_core']), ]); };
- Create an instance of your controller (preferably using a container)
class StatusControllerProvider implements ServiceProviderInterface
{
public function register(Container $container)
{
$container[StatusController::class] = function (Container $container) {
$configuration = $container['config'];
return new StatusController(
$container[StatusCheckerService::class],
);
};
}
}
- Add needed routes
$app->get('/status', StatusController::class . ':index');
$app->get('/status/details', StatusController::class . ':details');
- Access the above routes via your browser
/statusproduces the overall (global) status- if all services produce an
OKstatus it will output{"status":"OK"} - if any service fails it will output
{"status":"FAIL"} - if any service is in maintenance it will output
{"status":"MAINTENANCE"}
- if all services produce an
/status/detailsproduces more detailed output about the status of every individual service
{"database.default":"OK","database.other":"OK"}
{"database.default":"OK","database.other":"FAIL"}
统计信息
- 总下载量: 1.55k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-21