Giter Site home page Giter Site logo

supervisorphp / supervisor Goto Github PK

View Code? Open in Web Editor NEW
227.0 10.0 24.0 713 KB

PHP library for managing Supervisor through XML-RPC API

Home Page: http://supervisorphp.com

License: MIT License

PHP 87.37% Gherkin 12.00% Dockerfile 0.63%
supervisor php-library php hacktoberfest

supervisor's People

Contributors

andreybolonin avatar busterneece avatar gabrielpra1 avatar gl3n avatar prolic avatar raulp avatar sagikazarmark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

supervisor's Issues

Return Type notice

My logs are getting spammed with the following messages (using PHP 8.1.3):

Return type of Supervisor\Process::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/vendor/supervisorphp/supervisor/src/Process.php on line 107

Return type of Supervisor\Process::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/vendor/supervisorphp/supervisor/src/Process.php on line 115

Return type of Supervisor\Process::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/vendor/supervisorphp/supervisor/src/Process.php on line 91

Return type of Supervisor\Process::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/vendor/supervisorphp/supervisor/src/Process.php on line 99

There's no method for add Program To Group!

LIKE:

$supervisor->addProgramToGroup( 'testGroup', 'testProgram', array(
    'command' => 'tail -f /var/log/syslog',
    'autostart' => 'false',
    'autorestart' => 'true',
    'startsecs' => 1,
));

Reload configuration

So the configuration can be edited using supervisorphp/configuration and managament using supervisorphp/supervisor, but how can I tell supervisord to reload the new configuration once i changed the config file. Say I added a new program.

The supervisorctl has the update command, but the XML-RPC API and supervisorphp/supervisor seem to lack this functionality.

I can force supervisor to reload the new configuration by calling restart from php, but this is not an elegant solution.
Does somebody know a better way?

Thanks

Exception while stopping a process using prcoess name

I am trying to list own the Supervisor processes and then trying to stop some of them. Below is my code.

<?php

require_once __DIR__.'/vendor/autoload.php';
use Supervisor\Supervisor;
use Supervisor\Connector\XmlRpc;
use fXmlRpc\Client;
use fXmlRpc\Transport\HttpAdapterTransport;
use Ivory\HttpAdapter\Guzzle5HttpAdapter;

use Supervisor\Configuration\Configuration;
use Supervisor\Configuration\Section\Supervisord;
use Supervisor\Configuration\Section\Program;
use Indigo\Ini\Renderer;

use Supervisor\Exception\Fault;
use Supervisor\Exception\Fault\BadName;


class supervisor_apis{

    private function get_supervisor($ip, $port, $username = null, $password = null) {

        $guzzleClient = new \GuzzleHttp\Client ( [
            'auth' => [
                $username,
                $password
            ]
        ] );


        $client = new Client ( 'http://' . $ip .':' . $port . '/RPC2', new HttpAdapterTransport ( new Guzzle5HttpAdapter ( $guzzleClient ) ) );

        $connector = new XmlRpc ( $client );

        $supervisor = new Supervisor ( $connector );

        return $supervisor;
    }

    public function get_all_processes($ip = "127.0.0.1", $port = "9001"){
        $supervisor = self::get_supervisor($ip, $port);
        $processes = $supervisor->getAllProcesses();
        foreach($processes as &$process) {
            $payload = $process->getPayload();
            //echo $process . "\r\n";
            return $process;
        }

    }

    public function stop_process($ip = "127.0.0.1", $port = "9001", $name){
        $supervisor = self::get_supervisor($ip, $port);
        echo "*******\r\n" . "Now printing stop process result for " . $name . " \r\n";
        try{
            $supervisor->stopProcess($name);
        } catch (BadName $e) {
        // handle bad name error here
            echo $e;
        } catch (Fault $e) {
        // handle any other errors here
        }
    }
}

$sup = new supervisor_apis();
$process = $sup->get_all_processes();
echo $process . "\r\n";
$sup->stop_process("127.0.0.1", "9001", (string)$process);

?>

Here is the output

Now printing stop process result for pdf_convert_00 
exception 'Supervisor\Exception\Fault\BadName' with message 'BAD_NAME: pdf_convert_00' in /projects/mv2/millvi-system-monitoring/supervisor/lib/vendor/supervisorphp/supervisor/src/Exception/Fault.php:86
Stack trace
#0 /projects/mv2/test-system-monitoring/supervisor/lib/vendor/supervisorphp/supervisor/src/Connector/XmlRpc.php(47): Supervisor\Exception\Fault::create('BAD_NAME: pdf_c...', 10)
#1 /projects/mv2/test-system-monitoring/supervisor/lib/vendor/supervisorphp/supervisor/src/Supervisor.php(110): Supervisor\Connector\XmlRpc->call('supervisor', 'stopProcess', Array)
#2 /projects/mv2/test-system-monitoring/supervisor/lib/supervisor_apis.php(75): Supervisor\Supervisor->__call('stopProcess', Array)
#3 /projects/mv2/test-system-monitoring/supervisor/lib/supervisor_apis.php(75): Supervisor\Supervisor->stopProcess('pdf_convert_00')
#4 /projects/mv2/test-system-monitoring/supervisor/lib/supervisor_apis.php(94): supervisor_apis->stop_process('127.0.0.1', '9001', 'pdf_convert_00')

I am not sure if it is a genuine issue or I am doing something wrong here.

Can't connect processes

Hi everyone, please help me understand what I'm doing wrong. I am configuring Supervisor to run a few processes. It starts successfully, and I can access it in the browser using localhost:9001. However, when I try to enter a process name or use tail-stdout and tail-stderr, it either displays ERROR: unexpected rpc fault [30] FAILED or fails to open.

Please help me understand what mistake I might be making. I also want to mention that this is within a Docker container. I am using Docker Compose, and in my image, Supervisor is already installed. I mount its configuration file with the Compose file into /etc/supervisor/conf.d/supervisord.conf.

supervisord.conf

[supervisord]
nodaemon=true
loglevel=debug
logfile_maxbytes=0

[unix_http_server]
file=/tmp/supervisor.sock   ; (the path to the socket file)
chmod=0700                 ; socket file mode (default 0700)


[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket
serverurl=http://172.16.10.2:9001 ; use an http:// url to specify an inet socket
username=socialhub              ; (default is no username (open server))
password=socialhub              ; (default is no password (open server))

[inet_http_server]          ; inet (TCP) server disabled by default
port=172.16.10.2:9001         ; (ip_address:port specifier, *:port for all iface)
username=user              ; (default is no username (open server))
password=pass 

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[program:action-tracker]
command=/install-node.sh action-tracker
autostart=true
autorestart=true
startretries=3
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/var/log/action-tracker.err.log

[program:backend-services]
command=/install-php.sh
autostart=true
autorestart=true
startretries=3
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/var/log/backend.err.log

first page open
image

but, when enter process name , give this error
image

Time to switch to psr/log 3.x ?

php version already set to >= 8.1, psr/log needs update too...
composer conflicts now with other packages:

Problem 1
- Root composer.json requires supervisorphp/supervisor ^5.0 -> satisfiable by supervisorphp/supervisor[5.0.0].
- supervisorphp/supervisor 5.0.0 requires psr/log ^1.1 -> found psr/log[1.1.0, ..., 1.1.4] but it conflicts with your root composer.json require (^3.0).

Make Process object more robust

Process payload can be retrieved by simple calling getProcessInfo (or getAllProcessInfo).

Process object could do some processing on the payload (eg. wrapping time related data in DateTime)

There is no exception when starting multiple processes

If start single process which fail, then exception is thrown:

$supervisor->startProcess('queue-seller:seller-1');

Exception 'fXmlRpc\Exception\FaultException' with message 'NO_FILE: can't find command 'test''

But if start a group of processes:

$supervisor->startProcess('queue-seller:*');

the output is:

array(
  0 => array(
    'status' => 20,
    'group' => 'queue-seller',
    'name' => 'seller-8',
    'description' => 'NO_FILE: can\'t find command \'test\''
  ),
  1 => array(
    'status' => 20,
    'group' => 'queue-seller',
    'name' => 'seller-9',
    'description' => 'NO_FILE: can\'t find command \'test\''
  ),
)

How to correctly determine that an error occurred?

How to change numproc and reload?

I am trying to create a sort of autoscale. I can read config and processes etc.. but can I increase or decrease numproc using api and this package?

[Possible feature] supervisorbundle

Create a supervisorphp/supervisorbundle for symfony2.
This could allow managing the supervisor servers, configuration directly in the symfony config, console commands, etc etc.

Configuring RPC interface

Getting a error , where the RPC server cannot be found

PHP Fatal error:  Uncaught RuntimeException: Error creating resource: [message] fopen(http://127.0.0.1:9001/RPC2): failed to open stream: Connection refused
[file] /mnt/e/work/code/web/twitter/src/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php
[line] 324 in /mnt/e/work/code/web/twitter/src/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php:253
Stack trace:
#0 /mnt/e/work/code/web/twitter/src/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(335): GuzzleHttp\Handler\StreamHandler->createResource()
#1 /mnt/e/work/code/web/twitter/src/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(52): GuzzleHttp\Handler\StreamHandler->createStream()
#2 /mnt/e/work/code/web/twitter/src/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(66): GuzzleHttp\Handler\StreamHandler->__invoke()
#3 /mnt/e/work/code/web/twitter/src/vendor/guzzlehttp/guzzle/src/Middleware.php(29): GuzzleHttp\PrepareBodyMiddleware->__invoke()
#4 /mnt/e/work/code/web/twitter/src/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(70): GuzzleHttp\Mid in /mnt/e/work/code/web/twitter/src/vendor/lstrojny/fxmlrpc/src/fXmlRpc/Exception/TransportException.php on line 35

Does supervisord need to be configured to be able to use this library ? This page suggests so: http://supervisord.org/xmlrpc.html#rpcinterface-factories . But I can't find anything on how to configure this library.

What else could be the issue ?

Stopping Process Failed

Condition:

  • Supervisor 3.0
  • Server OS: Debian 4.7.2-5

While tried to stop a process, it return BAD_NAME.

...
$connector = new XmlRpc($client);
$supervisor = new Supervisor($connector);
$supervisor->stopProcess(process_name, true);
...

Attachment:

  • Get list of active process:
    screen shot 2017-02-22 at 14 25 44

Unix socket support

Hello,

As it not very straight-forward from the demo code and having played around quite a bit, would it be possible for you to include a Unix socket demo?

Return type is wrong for some Supervisor methods

The Supervisor methods startAllProcesses, startProcessGroup, stopProcessGroup, stopAllProcesses, signalProcessGroup, signalAllProcesses, tailProcessStdoutLog, tailProcessStderrLog and clearAllProcessLogs return value is wrong. They have bool return type, but actually return an array, as can be seen in supervisor documentation e.g. stopProcessGroup

* @method bool stopProcessGroup(string $name, boolean $wait = true)

I guess that the phpDoc should be changed in both https://github.com/supervisorphp/supervisor/blob/main/src/Supervisor.php and https://github.com/supervisorphp/supervisor/blob/main/src/SupervisorInterface.php

Thanks in advance for the work put in this library

Looking for maintainers

Despite being one of my first OSS projects, I have to let this one go. I have/had many plans, but I simply lack the time and since I don't actively use this anymore, it's somewhere on the bottom of my priority list.

Packagist stat says it's still used though (and it still remains my first OSS), so instead of just deprecating the project I would love to find maintainers who actually use it.

I am happy to discuss the future of the project with the new maintainer, share my thoughts what I imagined for the project, even review PRs once in a while, but other than that I give the future maintainer(s) full control (and the right to even deprecate the project if there is a viable successor).

If you feel like the next maintainer of this project, send me an email: [email protected]

must be of the type string in php7.4

PHP Fatal error: Uncaught TypeError: Return value of Supervisor\Event\Notification::getBody() must be of the type string, null returned in vendor/supervisorphp/event/src/Event/Notification.php:99

/**
 * @param array  $header
 * @param array  $payload
 * @param string $body
 */
public function __construct(array $header, array $payload, $body = null)
{
    $this->header = $header;
    $this->payload = $payload;
    $this->body = $body;
}

.... 

    /**
 * Returns the body
 *
 * @return string
 */
public function getBody(): string
{
    return $this->body;
}

Drop (official) Zend support?

According to @lstrojny it is not just slow, but unreliable. There were some issues related to it which was never resolved: indigophp-archive/supervisor#12, indigophp-archive/supervisor#17.

However @prolic has a bundle for it, which relies on the ZendConnector.

If zend support gets removed, fxmlrpc could be the only connector, so in this case connectors could be completely removed directly relying on ClientInterface. Since 3.0 is already tagged, it cannot make it until 4.0.

A support package could be created implementing ClientInterface, but using ZendXML-RPC as a background. Zend bundles can then rely on only-zend resources instead of third-party packages.

Any of the mentioned people: can you give me advice on this?

Guzzle4Bridge doesn't exit

fxmlrpc can be used but this example does not work because Guzzle4Bridge has been deleted.

$client = new Client(
    'http://127.0.0.1:9001/RPC2',
    new Guzzle4Bridge(new \GuzzleHttp\Client(['defaults' => ['auth' => ['user', '123']]]))
);

We used to ship our own bridges for interoperability with various HTTP clients but moved that responsibility to a 3rd party library called Ivory HTTP Adapter

...But Ivory HTTP Adapter is now deprecated... (lstrojny/fxmlrpc#56)

[Bug] fXmlRpc not found

There seems to be a bug with the example in the main README.

I have installed the package using composer, runing the example from the Usage part and i got fXmlRpc not found error.
It seems that the fXmlRpc is only installed for require-dev.
Can anyone confirm this issue?

Cheers
Tibor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.