定制 nordsec/status-checker 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. Install the library
composer require nordsec/status-checker
  1. 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']),
    ]);
};
  1. 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;
    }
);
  1. Run the command
bin/console status:check

WEB

  1. Install the library
composer require nordsec/status-checker
  1. 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']),
    ]);
};
  1. 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],
            );
        };
    }
}
  1. Add needed routes
$app->get('/status', StatusController::class . ':index');
$app->get('/status/details', StatusController::class . ':details');
  1. Access the above routes via your browser
  • /status produces the overall (global) status
    • if all services produce an OK status 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"}
  • /status/details produces 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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固