2017 © Pedro Peláez
 

library supervisor

PHP library for managing Supervisor through XML-RPC API

image

supervisorphp/supervisor

PHP library for managing Supervisor through XML-RPC API

  • Monday, April 23, 2018
  • by mark.sagikazar
  • Repository
  • 8 Watchers
  • 100 Stars
  • 197,134 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 12 Forks
  • 8 Open issues
  • 15 Versions
  • 6 % Grown

The README.md

Supervisor

Latest Version Software License Test Suite Total Downloads, (*1)

PHP library for managing Supervisor through XML-RPC API., (*2)

Install

Via Composer, (*3)

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., (*4)

In the example below, we will use the popular Guzzle HTTP client library., (*5)

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

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., (*7)

// 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., (*8)

/** @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., (*9)

Further info

You can find the Supervisor XML-RPC documentation here: http://supervisord.org/api.html, (*10)

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., (*11)

Contributing

Please see CONTRIBUTING for details., (*12)

Testing

$ composer test

Functional tests (behat):, (*13)

$ behat

Docker Image

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

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:, (*15)

Credits

License

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

The Versions

23/04 2018

dev-master

9999999-dev http://supervisorphp.com

PHP library for managing Supervisor through XML-RPC API

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Márk Sági-Kazár

supervisor process manager

16/05 2015

dev-connector_deprecation

dev-connector_deprecation http://supervisorphp.com

PHP library for managing Supervisor through XML-RPC API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Márk Sági-Kazár

supervisor process manager

13/07 2014

v1.2.1

1.2.1.0 https://indigophp.com

PHP library for Supervisord

  Sources   Download

MIT

The Requires

 

The Development Requires

by Márk Sági-Kazár

supervisor process manager

06/05 2014

v1.2.0

1.2.0.0 https://indigophp.com

PHP library for Supervisord

  Sources   Download

MIT

The Requires

 

The Development Requires

by Márk Sági-Kazár

supervisor process manager

29/01 2014

v1.1.1

1.1.1.0 https://indigophp.com

PHP library for Supervisord

  Sources   Download

MIT

The Requires

 

The Development Requires

by Márk Sági-Kazár

supervisor process manager

20/01 2014

v1.1.0

1.1.0.0 http://indigophp.com

PHP library for Supervisord

  Sources   Download

MIT

The Requires

 

The Development Requires

by Márk Sági-Kazár

17/01 2014

v1.0.0

1.0.0.0 http://indigophp.com

PHP library for Supervisord

  Sources   Download

MIT

The Requires

 

The Development Requires

by Márk Sági-Kazár

16/12 2013

v1.0-alpha

1.0.0.0-alpha

Supervisor PHP library

  Sources   Download

MIT

The Requires

 

by Márk Sági-Kazár