Symfomaniacs!
Let's say I have this code in my controller:
for ($i = 0; $i <= 3; $i++)
{
$command = 'php ' . $kernel->getRootDir() . '/console Educa:ExecuteJob '
. $i . ' --env=' . $kernel->getEnvironment();
$logger->addInfo("Executing command: ".$command);
$process = new Process($command);
$process->disableOutput();
$process->start();
}
//sleep(5);
return $this->render(...);
and the ExecuteJob takes about 5 seconds to execute. Inside the console command, I have a logger->addInfo() at both the beginning and end script.
If I uncomment the sleep(5) line they both print. If I don't, only the initial line prints in the log, which must mean that when the controller scripts end, it stops all processes, am I wrong?
Is there any way to workaround this? I'm open to change the design, I just want to execute background stuff without having to wait to render the page (is not even relevant for that page)
PS: I'm looking for a way to run background tasks that plays nice with Symfony2, not weird php hacks or cron jobs. I know about those. I also don't want to setup a MQ queue. It's kind of overkill for what I'm trying.