All Projects → supervisorphp → Supervisor

supervisorphp / Supervisor

Licence: mit
PHP library for managing Supervisor through XML-RPC API

Projects that are alternatives of or similar to Supervisor

Titanium
A keyboard-driven web browser written in Rust
Stars: ✭ 163 (+0%)
Mutual labels:  hacktoberfest
Rele
Easy to use Google Pub/Sub
Stars: ✭ 164 (+0.61%)
Mutual labels:  hacktoberfest
Www Rpcs3
This is a responsive website designed to house and promote the progress of RPCS3, an open-source PlayStation 3 emulator and debugger written in C++. This repository is regularly updated.
Stars: ✭ 164 (+0.61%)
Mutual labels:  hacktoberfest
Tip4commit
Donate bitcoins to open source projects or make commits and get tips for it.
Stars: ✭ 163 (+0%)
Mutual labels:  hacktoberfest
Device Detector
The Universal Device Detection library will parse any User Agent and detect the browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), brand and model.
Stars: ✭ 2,106 (+1192.02%)
Mutual labels:  hacktoberfest
Rapidbay
Self-hosted torrent video streaming service compatible with Chromecast and AppleTV deployable in the cloud
Stars: ✭ 163 (+0%)
Mutual labels:  hacktoberfest
Cutcode
A browser extension that enables double click to copy code snippet from stack overflow.
Stars: ✭ 163 (+0%)
Mutual labels:  hacktoberfest
Matrix Appservice Slack
A Matrix <--> Slack bridge
Stars: ✭ 164 (+0.61%)
Mutual labels:  hacktoberfest
Sponsorblock
Skip YouTube video sponsors (browser extension)
Stars: ✭ 3,627 (+2125.15%)
Mutual labels:  hacktoberfest
Go Openvswitch
Go packages which enable interacting with Open vSwitch and related tools. Apache 2.0 Licensed.
Stars: ✭ 164 (+0.61%)
Mutual labels:  hacktoberfest
Web Term
📺 A fullscreen terminal in your browser.
Stars: ✭ 163 (+0%)
Mutual labels:  hacktoberfest
Jackson Core
Core part of Jackson that defines Streaming API as well as basic shared abstractions
Stars: ✭ 2,003 (+1128.83%)
Mutual labels:  hacktoberfest
Terrastories
Terrastories is a geostorytelling application built to enable local communities to locate and map their own oral storytelling traditions about places of significant meaning or value to them. Check out our Wiki for open source development information.
Stars: ✭ 158 (-3.07%)
Mutual labels:  hacktoberfest
Stat.ink
https://stat.ink/
Stars: ✭ 163 (+0%)
Mutual labels:  hacktoberfest
Fuzzinator
Fuzzinator Random Testing Framework
Stars: ✭ 164 (+0.61%)
Mutual labels:  hacktoberfest
Klooni1010
libGDX game based on the original 1010!
Stars: ✭ 163 (+0%)
Mutual labels:  hacktoberfest
Templates
Tasmota Device Templates Repository. Your one stop shop to get templates for devices running Tasmota!
Stars: ✭ 162 (-0.61%)
Mutual labels:  hacktoberfest
Image Png
PNG decoding and encoding library in pure Rust
Stars: ✭ 164 (+0.61%)
Mutual labels:  hacktoberfest
Buttercup Browser Extension
🌏 Buttercup browser extension
Stars: ✭ 164 (+0.61%)
Mutual labels:  hacktoberfest
Django Loci
Reusable Django app for storing geographic and indoor coordinates. Maintained by the OpenWISP Project.
Stars: ✭ 164 (+0.61%)
Mutual labels:  hacktoberfest

Supervisor

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:^6.0 php-http/guzzle6-adapter http-interop/http-factory-guzzle php-http/httplug php-http/message

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

// Create Guzzle 6 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\HttpAdapterTransport(
        new \Http\Message\MessageFactory\GuzzleMessageFactory(),
        new \Http\Adapter\Guzzle6\Client($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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].