How to run Symfony task in background from action correctly?

What is the right way to run symfony tasks in a separate process. My first suggestion would be to use fork / exec, but according to this, you cannot do this with anything where open file descriptors or connections are stored (e.g. MySQL). So this does not look like his version. Another option is to do it exec('symfony taskname &'), but it looks like a hack. Is this the best I can do? Is there a third way?

+5
source share
3 answers

Here is how I did it:

exec('nohup ' . sfConfig::get('sf_root_dir') . '/symfony TASKNAME >/dev/null &');

STDOUT, ( /dev/null, ). , Symfony, .

. .

+3

, , . , - ( , , beanstalkd). - (), .

+4

Php does not know multithreading.
And yes, this is a big flaw in php IMO.
There is a way to do multithreading, but this is not recommended. It is complex and it is ugly, and it asks without causing problems.

So, I think the best you can do is something like exec or maby somthing, like calling a web service like a call?

-8
source

All Articles