mondalaci/supervisor-client

此包已被弃用且不再维护。作者建议使用 supervisorphp/supervisor 包。

PHP 中的 supervisord 库

dev-master 2015-01-19 12:22 UTC

This package is not auto-updated.

Last update: 2019-02-20 17:20:38 UTC


README

弃用通知

尽管这个包已知功能完整且无错误,但我不再主动开发它。我会尝试解决问题和拉取请求,但更鼓励您使用更完整的库 SupervisorPHP。

https://github.com/supervisorphp/supervisor

详情请见 http://supervisorphp.com

supervisord PHP 客户端

一个利用 其 XML-RPC 接口supervisor PHP 客户端库。

此包已提交到 Packagist,您可以从那里安装它 [此处](https://packagist.org.cn/packages/mondalaci/supervisor-client)

使用方法

  1. 包含库并导入类
require 'SupervisorClient.php';
use SupervisorClient\SupervisorClient;

2A) 为 [unix_http_server] 配置实例化客户端

$supervisor = new SupervisorClient('unix:///var/run/supervisor.sock');

2B) 为 [inet_http_server] 配置实例化客户端

$supervisor = new SupervisorClient('YourDomain.com', 9001);
  1. 设置身份验证和/或连接超时
$supervisor->setAuth('username', 'password');
$supervisor->setTimeout(10000);  // microseconds
  1. 进行 RPC 调用并输出结果
$allProcessInfo = $supervisor->getAllProcessInfo();
var_dump($allProcessInfo);

RPC 调用的输出结果

array(2) {
  [0]=>
  array(14) {
    ["description"]=>
    string(24) "pid 3194, uptime 4:45:46"
    ["pid"]=>
    int(3194)
    ["stderr_logfile"]=>
    string(0) ""
    ["stop"]=>
    int(0)
    ["logfile"]=>
    string(49) "/var/log/supervisor/program1.log"
    ["exitstatus"]=>
    int(0)
    ["spawnerr"]=>
    string(0) ""
    ["now"]=>
    int(1346181399)
    ["group"]=>
    string(25) "group1"
    ["name"]=>
    string(25) "program1"
    ["statename"]=>
    string(7) "RUNNING"
    ["start"]=>
    int(1346164253)
    ["state"]=>
    int(20)
    ["stdout_logfile"]=>
    string(49) "/var/log/supervisor/program1.log"
  }
  [1]=>
  array(14) {
    ["description"]=>
    string(24) "pid 3241, uptime 4:45:45"
    ["pid"]=>
    int(3241)
    ["stderr_logfile"]=>
    string(0) ""
    ["stop"]=>
    int(0)
    ["logfile"]=>
    string(42) "/var/log/supervisor/program2.log"
    ["exitstatus"]=>
    int(0)
    ["spawnerr"]=>
    string(0) ""
    ["now"]=>
    int(1346181399)
    ["group"]=>
    string(8) "group2"
    ["name"]=>
    string(18) "program2"
    ["statename"]=>
    string(7) "RUNNING"
    ["start"]=>
    int(1346164254)
    ["state"]=>
    int(20)
    ["stdout_logfile"]=>
    string(42) "/var/log/supervisor/program2.log"
  }
}

享受吧!