此功能导入联系人。我想启动一个在后台合并联系人的进程。我正在使用 Process 类。但是,它无法成功运行,因为当请求将响应返回给客户端时,它也会终止该进程。在 http 请求结束后,我该如何保持我的进程处于活动状态?
注意:在我的本地主机中工作正常,但在我的在线远程服务器中却不行。也许原因是 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"];
}