Created
September 5, 2017 10:00
-
-
Save standa/5bf27b1d6dec44138007f325943191e3 to your computer and use it in GitHub Desktop.
Call XMLRPC method supervisor.getAllProcessInfo without php-xmlrpc installed via unix socket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getSupervisorAllProcessInfo(): string | |
{ | |
$xml = '"<?xml version="1.0" encoding="utf-8"?>' . | |
'<methodCall><methodName>supervisor.getAllProcessInfo</methodName><params/></methodCall>"'; | |
$req = "POST /RPC2 HTTP/1.0\r\nContent-Type: text/xml\r\nContent-Length: " . strlen($xml) . "\r\n\r\n$xml"; | |
$s = stream_socket_client('unix:///var/run/supervisor.sock', $errNo, $errStr); | |
if (! $s) { | |
$this->logError("Could not connect to unix:///var/run/supervisor.sock($errNo) : $errStr"); | |
return []; | |
} | |
fwrite($s, $req . "\r\n"); | |
$rawResult = fread($s, 102400); | |
$result = simplexml_load_string(strstr($rawResult, '<?xml')); | |
return (string) $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment