首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Symfony未捕获异常-‘进程已用信号"9“发出信号

Symfony未捕获异常-‘进程已用信号"9“发出信号
EN

Stack Overflow用户
提问于 2015-10-15 19:06:39
回答 2查看 10.2K关注 0票数 3

我在尝试使用Phantomjs和Symfony的Process和Reposonse文件创建PDF文档时遇到此错误。

这是我收到的错误消息

致命错误:未捕获异常'Symfony\Component\Process\Exception\RuntimeException‘,并显示消息“进程已用信号”9“发出信号。”

下面是我的代码:控制器文件

代码语言:javascript
复制
    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);
    }

}

这是我的视图文件:

代码语言:javascript
复制
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');

    }
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 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操作类型。

票数 2
EN

Stack Overflow用户

发布于 2021-03-24 18:29:44

当您更改主管订单配置时,也会发生这种情况。

当您更改配置并运行reread和update命令时,supervisord将向子进程发送停止信号。如果它们没有在stopwaitsecs配置变量指定的时间内完成,则会用9个信号终止它们。

在我的例子中,我使用的是Laravel,并且我必须将stopwaitsecs值设置为大于我运行时间最长的作业(正如文档中实际提到的那样)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33146878

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档