This function imports contacts. I would like to launch one process for merging the contacts in background. I'm using the Process class. However, It is not working successfully because when the request returns the response to the client, it kills the process as well. How can I do to keep my process alive after the http request ends?
NOTE: In my localhost works fine but not in my online remote server. Maybe the cause is the 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"];
}