yuav/gearmanadmin

Gearman admin library to get status and version, and list workers, set maxqueue or shutdown Gearman server

Installs: 1 065

Dependents: 0

Stars: 2

Watchers: 1

Forks: 2

Language: PHP

1.0.2 2013-08-22 06:04 UTC

README

PHP Client for the Gearman Administrative Protocol

Total Downloads Latest Stable Version

Installing via Composer (recommended)

  • Install composer in your project:
curl -s http://getcomposer.org/installer | php
  • Create a composer.json file in your project root:
{
    "require": {
        "yuav/gearmanadmin": "1.*"
    }
}
  • Install via composer
php composer.phar install

Usage

<?php

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

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

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

From Gearman documentation:

Administrative Protocol

The Gearman job server also supports a text-based protocol to pull information and run some administrative tasks. This runs on the same port as the binary protocol, and the server differentiates between the two by looking at the first character. If it is a NULL (\0), then it is binary, if it is non-NULL, that it attempts to parse it as a text command. The following commands are supported:

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.