一旦请求完成,Symfony Process组件就会死掉

时间:2015-12-15 18:25:58

标签: php symfony asynchronous symfony-process

此功能导入联系人。我想在后台启动一个合并联系人的流程。我正在使用Process类。但是,它无法成功运行,因为当请求将响应返回给客户端时,它也会终止该进程。如何在http请求结束后保持我的进程处于活动状态?

注意:在我的localhost工作正常但不在我的在线远程服务器中。也许原因是php.ini

use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

public function importAction(Request $request)
{
    // .....

    //We start the first fusion process
    try {
        $process = new Process('php ' . $this->get('kernel')->getRootDir() . '/console fusion:contact:one_user ' . $user->getId());
        $process->setTimeout(500);
        $process->start();
    } catch (\Exception $e) {
        throw new \Exception($e);
    }

    return ["error" => "0", "message" => "Importation successfully"];
}

0 个答案:

没有答案