Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Blackfire评测PHP shell脚本应用程序或工作程序_Php_Worker_Beanstalkd_Blackfire - Fatal编程技术网

如何使用Blackfire评测PHP shell脚本应用程序或工作程序

如何使用Blackfire评测PHP shell脚本应用程序或工作程序,php,worker,beanstalkd,blackfire,Php,Worker,Beanstalkd,Blackfire,我注意到,当我有一个没完没了的工作人员时,我无法分析PHP shell脚本。因为当它被杀死时,它不会发送探测器 我应该做什么更改?当您试图分析一个运行无止境循环的工作人员时。在这种情况下,您必须手动编辑代码以删除无止境循环,或者插入代码以手动调用探测器()的close()方法 这是因为只有在调用close()方法时,才会将数据发送到代理(除非您将其终止,否则会在程序结束时自动调用该方法) 您可以使用Blackfire探测器附带的BlackfireProbe类手动插入某些代码: // Get th

我注意到,当我有一个没完没了的工作人员时,我无法分析PHP shell脚本。因为当它被杀死时,它不会发送探测器


我应该做什么更改?

当您试图分析一个运行无止境循环的工作人员时。在这种情况下,您必须手动编辑代码以删除无止境循环,或者插入代码以手动调用探测器()的close()方法

这是因为只有在调用close()方法时,才会将数据发送到代理(除非您将其终止,否则会在程序结束时自动调用该方法)

您可以使用Blackfire探测器附带的BlackfireProbe类手动插入某些代码:

// Get the probe main instance
$probe = BlackfireProbe::getMainInstance();
// start profiling the code
$probe->enable();

// Calling close() instead of disable() stops the profiling and forces the  collected data to be sent to Blackfire:

// stop the profiling
// send the result to Blackfire
$probe->close();

与自动插装一样,只有在通过Companion或blackfire CLI实用程序运行代码时,配置文件才处于活动状态。如果没有,所有调用都会转换为noop。

我不知道,可能在2015年以下页面不存在,但现在您可以通过以下方式进行分析:


现在,您可以将信号SIGUSR1发送到此工作进程的进程,
LoopClient
将开始分析。它将监听方法
消费的10次迭代,并发送最后一次探测。之后,它将停止分析。

希望页面始终存在,否则您可能应该包含该页面上的代码/文本,除非您是该站点的“所有者”;-)你知道Stack对link only的感觉。
$blackfire = new LoopClient(new Client(), 10);
$blackfire->setSignal(SIGUSR1);
$blackfire->attachReference(7);
$blackfire->promoteReferenceSignal(SIGUSR2);

for (;;) {
    $blackfire->startLoop($profileConfig);

    consume();

    $blackfire->endLoop();

    usleep(400000);
}