承接 supervisorphp/supervisor 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

supervisorphp/supervisor

Composer 安装命令:

composer require supervisorphp/supervisor

包简介

PHP library for managing Supervisor through XML-RPC API

README 文档

README

Latest Version Software License Test Suite Total Downloads

PHP library for managing Supervisor through XML-RPC API.

Install

Via Composer

composer require supervisorphp/supervisor

Usage

This library depends on the fast and powerful fXmlRpc library, which supports a number of adapters to use your preferred HTTP client to make connections.

In the example below, we will use the popular Guzzle HTTP client library.

This example requires some additional libraries to function. To include the necessary extra components, you can run:

composer require guzzlehttp/guzzle:^7.0

This example shows how to pass authentication credentials to Guzzle, initiate the fXmlRpc client, and pass that to SupervisorPHP.

// Create Guzzle HTTP client
$guzzleClient = new \GuzzleHttp\Client([
    'auth' => ['user', '123'],
]);

// Pass the url and the guzzle client to the fXmlRpc Client
$client = new fXmlRpc\Client(
    'http://127.0.0.1:9001/RPC2',
    new fXmlRpc\Transport\PsrTransport(
        new GuzzleHttp\Psr7\HttpFactory(),
        $guzzleClient
    )
);

// Or, if connecting via a Unix Domain Socket
$guzzleClient = new \GuzzleHttp\Client([
    'curl' => [
        \CURLOPT_UNIX_SOCKET_PATH => '/var/run/supervisor.sock',
    ],
]);

$client = new fXmlRpc\Client(
    'http://localhost/RPC2',
    new fXmlRpc\Transport\PsrTransport(
        new GuzzleHttp\Psr7\HttpFactory(),
        $guzzleClient
    )
);

// Pass the client to the Supervisor library.
$supervisor = new Supervisor\Supervisor($client);

// returns Process object
$process = $supervisor->getProcess('test_process');

// returns array of process info
$supervisor->getProcessInfo('test_process');

// same as $supervisor->stopProcess($process);
$supervisor->stopProcess('test_process');

// Don't wait for process start, return immediately
$supervisor->startProcess($process, false);

// returns true if running
// same as $process->checkState(Process::RUNNING);
$process->isRunning();

// returns process name
echo $process;

// returns process information
$process->getPayload();

Exception handling

For each possible fault response there is an exception. These exceptions extend a common exception, so you are able to catch a specific fault or all. When an unknown fault is returned from the server, an instance if the common exception is thrown. The list of fault responses and the appropriate exception can be found in the class.

/** @var \Supervisor\Supervisor $supervisor */

try {
	$supervisor->startProcess('process', true);
} catch (\Supervisor\Exception\Fault\BadNameException $e) {
	// handle bad name error here
} catch (\Supervisor\Exception\SupervisorException $e) {
	// handle any other errors here
}

Configuration and Event listening

Configuration and Event components have been moved into their own repository.

Further info

You can find the Supervisor XML-RPC documentation here: http://supervisord.org/api.html

Notice

If you use PHP XML-RPC extension to parse responses (which is marked as EXPERIMENTAL). This can cause issues when you are trying to read/tail log of a PROCESS. Make sure you clean your log messages. The only information I found about this is a comment.

Contributing

Please see CONTRIBUTING for details.

Testing

$ composer test

Functional tests (behat):

$ behat

Docker Image

This repository ships with a Docker Compose configuration and a Dockerfile for easy testing. Tests can be run via:

docker-compose run --rm ci

Deprecated Libraries

While this tries to be a complete Supervisor client, this isn't the first one. However some authors decided to deprecate their packages in favor of this:

Credits

License

The MIT License (MIT). Please see License File for more information.

supervisorphp/supervisor 适用场景与选型建议

supervisorphp/supervisor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.09M 次下载、GitHub Stars 达 244, 最近一次更新时间为 2015 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「supervisor」 「process manager」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 supervisorphp/supervisor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 supervisorphp/supervisor 我们能提供哪些服务?
定制开发 / 二次开发

基于 supervisorphp/supervisor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2.09M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 249
  • 点击次数: 25
  • 依赖项目数: 17
  • 推荐数: 0

GitHub 信息

  • Stars: 244
  • Watchers: 9
  • Forks: 24
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-13