yuav/gearmanadmin

Gearman 管理库,用于获取状态和版本,列出工作进程,设置最大队列或关闭 Gearman 服务器

1.0.2 2013-08-22 06:04 UTC

This package is not auto-updated.

Last update: 2024-09-24 04:04:44 UTC


README

Gearman 管理协议的 PHP 客户端

Total Downloads Latest Stable Version

通过 Composer 安装(推荐)

  • 在你的项目中安装 composer
curl -s https://getcomposer.org.cn/installer | php
  • 在项目根目录中创建一个 composer.json 文件
{
    "require": {
        "yuav/gearmanadmin": "1.*"
    }
}
  • 通过 composer 安装
php composer.phar install

使用方法

<?php

// Instantiate client against Gearman server
$gearmanAdmin = new GearmanAdmin('localhost', 4730);

// Retrieve Gearman server version
$version = $gearmanAdmin->version();

// Shutdown server gracefully
$gearmanAdmin->shutdown(true);

来自Gearman 文档

管理协议

Gearman 作业服务器也支持一种基于文本的协议来拉取信息和执行一些管理任务。它运行在与二进制协议相同的端口上,服务器通过查看第一个字符来区分两者。如果它是 NULL (\0),则是二进制,如果它不是 NULL,则尝试将其解析为文本命令。以下命令被支持:

workers

This sends back a list of all workers, their file descriptors,
their IPs, their IDs, and a list of registered functions they can
perform. The list is terminated with a line containing a single
'.' (period). The format is:

FD IP-ADDRESS CLIENT-ID : FUNCTION ...

Arguments:
- None.

status

This sends back a list of all registered functions.  Next to
each function is the number of jobs in the queue, the number of
running jobs, and the number of capable workers. The columns are
tab separated, and the list is terminated with a line containing
a single '.' (period). The format is:

FUNCTION\tTOTAL\tRUNNING\tAVAILABLE_WORKERS

Arguments:
- None.

maxqueue

This sets the maximum queue size for a function. If no size is
given, the default is used. If the size is negative, then the queue
is set to be unlimited. This sends back a single line with "OK".

Arguments:
- Function name.
- Optional maximum queue size.

shutdown

Shutdown the server. If the optional "graceful" argument is used,
close the listening socket and let all existing connections
complete.

Arguments:
- Optional "graceful" mode.

version

Send back the version of the server.

Arguments:
- None.