I would like to create a background process in Symfony2, using the Process component and run it in background, like this:
$process = new Process('php myfile.php --option1 --option2');
$process->start();
The script which I want to run here would run indefinetely (while (true)
or something like that) and should be possible to kill from a console command or from a controller.
The question is - how can I access such a process in Symfony (e.g. from a controller) from a different context than it was created? That is - without the original Process
instance? Let's say a request to a route create_process
starts the process, then a request to kill_process
should kill it. Is it even possible?
One way I can think of is serializing the process object and storing in in the database but it seems there could be lots of problems with this solution.