php怎么更改进程用户名,通过PHP API动态更改管理程序进程

我设置了

Supervisor,用于管理我的工作流程.

现在,我想通过使用PHP API动态更改进程(停止某些进程并启动新进程).

我发现这个library似乎对我正在尝试的东西很有用.具体来说,我使用this更改配置,使用this管理主管.

我已设置此库并具有以下示例代码,似乎运行良好(从here和here)

require './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;

//Create GuzzleHttp client

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

// Pass the url and the guzzle client to the XmlRpc Client

$client = new Client(

'http://127.0.0.1:9001/RPC2',

new HttpAdapterTransport(new Guzzle5HttpAdapter($guzzleClient))

);

// Pass the client to the connector

// See the full list of connectors bellow

$connector = new XmlRpc($client);

$supervisor = new Supervisor($connector);

$processes = $supervisor->getAllProcesses();

foreach ($processes as $key => $processInfo) {

echo $processInfo . "\r\n";

}

try{

$supervisor->stopProcess('video_convert_02');

}

catch(Exception $e){

echo "\r\n Exception-> " . $e->getMessage();

}

$config = new Configuration;

$renderer = new Renderer;

$section = new Supervisord(['identifier' => 'supervisor']);

$config->addSection($section);

$section = new Program('test', ['command' => 'cat']);

$config->addSection($section);

echo "\r\n Config \r\n" . $renderer->render($config->toArray());

//Not sure how to use this config information to launch supervisor processes.

?>

输出如下:

pdf_convert_00

pdf_convert_01

video_convert_00

video_convert_01

video_convert_02

video_convert_03

Exception-> BAD_NAME: video_convert_02

Config

[supervisord]

identifier = supervisor

[program:test]

command = cat

我这里有两个问题:

>我不明白为什么它会抛出异常,当我试图阻止这个过程时

>如何使用配置信息启动新进程?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值