This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Best practice for background tasks

New topics about Symfony 2 should go here

Best practice for background tasks

by xDaizu » Wed Apr 22, 2015 9:12 am

As you can read in this question in SO http://stackoverflow.com/questions/29772116/symfony2-background-process-running-after-script-ends I'm looking for a good way of executing background tasks in Symfony2.
This far:

A) Calling a background Process doesn't work, because when the script ends, it kills all processes, and they may not have finished. I want to be able to return a return and leave the task running, the user doesn't need feedback from it.

B) Calling the task from an event listener to " kernel.terminate " doesn't seem to be specific enough. As far as I understand it, you bind it to ALL "kernel.terminate" events, which is bonkers, I just want to run one task (or console command, or whatever) after one specific action in one specific controller ends.

C) Calling a cron job or hacky php is discarded for not being inside of a "framework" philosophy. It just breaks the flow. And it's not cross-platform. And it requires control over the host machine you may not have. And more reasons.

So... which are my options here? Because I feel there must be a way to do this. And if there isn't, I feel it should be a priority. :?~:-?~:???:
xDaizu
Junior Member
 
Posts: 3
Joined: Tue Apr 07, 2015 10:55 am