How to execute a command via proc_open and not wait for the execution to end?

1

I have a Symfony2 project that generates a PDF from an HTML with the KnpSnappyBundle bundle, which has the dependency of the KnpSnappy bundle and which in turn abstracts with the wkhtmltopdf executable. / p>

This binary is executed with the appropriate parameters through the proc_open function of PHP according to the line below:

$process = proc_open($this->command, $descriptorspec, $pipes, null, $this->env);

In the tests I did, I noticed that the process gets stuck with the Apache process. So, if the server is overloaded, the Apache response may take too long, which is not an option.

Changing the function as well as the functionality of the bundle is also not an option. The only thing I can do is modify the parameters of the proc_open function so that the process does not get stuck with Apache - this if that option exists.

Has anyone done something like this or do you know of a workaround?

    
asked by anonymous 10.02.2014 / 13:49

1 answer

1

Hello, I had a similar problem and resolved using a queue system and putting the script to run asynchronously.

Take a look at Gearman and see how simple it is to use: GearmanClient :: doBackground

    
10.02.2014 / 17:52