supervisorphp / supervisor Goto Github PK
View Code? Open in Web Editor NEWPHP library for managing Supervisor through XML-RPC API
Home Page: http://supervisorphp.com
License: MIT License
PHP library for managing Supervisor through XML-RPC API
Home Page: http://supervisorphp.com
License: MIT License
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
LIKE:
$supervisor->addProgramToGroup( 'testGroup', 'testProgram', array(
'command' => 'tail -f /var/log/syslog',
'autostart' => 'false',
'autorestart' => 'true',
'startsecs' => 1,
));
[Composer\Downloader\TransportException]
The "https://packagist.phpcomposer.com/p/symfony/css-selector%241e089491f7775d6a913ad68150490ac8e507aaa692e6e51e8da2fc06cfcdbbf1.json" file could not be downloaded (HTTP/1.1 404 Not Fo
und)
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
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.
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
Why package has "minimum-stability": "dev" in composer.json for all versions? Is there significant reason for that?
UPD: sorry, problems with my configuration
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).
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)
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?
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?
Create a supervisorphp/supervisorbundle for symfony2.
This could allow managing the supervisor servers, configuration directly in the symfony config, console commands, etc etc.
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 ?
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?
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
Line 33 in 61361a8
Thanks in advance for the work put in this library
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]
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;
}
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?
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)
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
I can't connect to my supervisor service give me that error every time i trie to get process
An error occurred when fetching the URI "http://localhost:9001/RPC2" with the adapter "guzzle6" ("cURL error 7: Failed to connect to localhost port 9001: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)").
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.