我在尝试使用Phantomjs和Symfony的Process和Reposonse文件创建PDF文档时遇到此错误。
这是我收到的错误消息
致命错误:未捕获异常'Symfony\Component\Process\Exception\RuntimeException‘,并显示消息“进程已用信号”9“发出信号。”
下面是我的代码:控制器文件
namespace PhantomFox\Capture;
use PhantomFox\Views\View;
use Symfony\Component\Process\Process;
use Symfony\Component\HttpFoundation\Response;
class Capture
{
protected $view;
protected $pdf;
public function __construct()
{
$this->view = new View;
}
public function load($filename, array $data = [])
{
$view = $this->view->load($filename, $data);
$this->pdf = $this->captureImage($view);
}
public function respond($filename)
{
$response = new Response(file_get_contents($this->pdf), 200, [
'Content-Description' => 'File Transfer',
'Content-Disposition' => 'attachment; filename="' . $filename . '"',
'Content-Transfer-Encoding' => 'binary',
'Content-Type' => 'application/pdf',
]);
unlink($this->pdf);
$response->send();
}
protected function captureImage($view)
{
$path = $this->writeFile($view);
$this->phantomProcess($path)->setTimeout(10)->mustRun();
return $path;
}
protected function writeFile($view)
{
file_put_contents($path = 'app/tmp/storage/' . md5(uniqid()) . '.pdf' , $view);
return $path;
}
public function phantomProcess($path)
{
return new Process('app/bin/phantomjs capture.js ' . $path);
}
}这是我的视图文件:
class AppController extends Controller {
public function index() {
$this->capture->load('index.html', [
'order' => '123456',
'name' => 'Wes Murray',
'amount' => 100.00,
]);
$this->capture->respond('index.pdf');
}
}发布于 2015-10-15 19:19:59
根据这篇文章,The process has been signaled with signal "9",这可能与你的主机内存不足有关。
i.am.michiel 3月4日7:56
这实际上可能是一个资源问题。您可能需要检查服务器的虚拟硬件。
Dmitry Mar 4在11:56
@i.am.michiel,谢谢,虚拟服务器内存不足。
检查您的服务器设置和硬件是否适合您要运行的PDF操作类型。
发布于 2021-03-24 18:29:44
当您更改主管订单配置时,也会发生这种情况。
当您更改配置并运行reread和update命令时,supervisord将向子进程发送停止信号。如果它们没有在stopwaitsecs配置变量指定的时间内完成,则会用9个信号终止它们。
在我的例子中,我使用的是Laravel,并且我必须将stopwaitsecs值设置为大于我运行时间最长的作业(正如文档中实际提到的那样)。
https://stackoverflow.com/questions/33146878
复制相似问题