2

i have long running task which i have incorporated as a Process in my symfony project. This is how i call the process

$rootDir = $this->get('kernel')->getRootDir();
$adk_process = new Process(
  'php ../bin/console app:adkaction ' . $numcampaigns . ', ' . $timezone . ',' . $depdate);
$adk_process->setWorkingDirectory($rootDir);
$adk_process->setOptions(['suppress_errors' => false]);
$adk_process->setTimeout(null);
$adk_process->start();

while ($adk_process->isRunning()) {
      $currprogress = $adk_process->getIncrementalOutput();
       return $this->render('BackEnd/user.html.twig',[
              'form'=>$form->createView(),
              'currprogress' => $currprogress
              ]);
}

My process currently does not have any output (it is parsing xml file and pushing data to db). When done currprogress variable should be pushes into my .twig template when it will populate progress bar.

I need to show the progress of file parsing (i.e. how many items were processed as it can be up to 100k lines and the process can run for 2-3 hours).

At the moment i cannot get the the incremental output from my process to push it over to my temaplte. What would be the best way to do it!

Sky21.86
  • 627
  • 2
  • 9
  • 26
  • I would create a `running_process` table, and create an entry for each running process. From the process you can update the corresponding entry, and from the frontend you pull a specific URL at a regular rate which responds with the progress information from the database – Florian Moser Mar 29 '17 at 09:49
  • Thanks @Florian Moser, i was more looking into non db based solution as with this it seems like i will need to pass each progress step to db and call method to get that data from DB which can potentially slow down the application. I did figure out how to get the process to run on the background those - now i just need to get the process of the progress, running on the background. Any idea on how to do that? – Sky21.86 Mar 30 '17 at 12:52

0 Answers0