Hello, @nidup , for some purposes I need to run few imports one by one.
So I created console command which runs two commands like described here.
The problem is when I run "wrapper" command, the first internal command runs successfully, but the second runs unexpectedly. On terminal it duplicates messages about each job step execution point - job was started, completed etc. And it doesn't read and process items in file. But when i remove call of first command, second command runs as expected. So it seems like first execution influences somehow (maybe by some sharing context) on second command, and I got unexpected behavior. Do you have any ideas regarding this?
Regards, Viktor & Alexandr.
Hi @NovikovViktor
I assume you run "batch:job" command twice in the wrapper command.
The batch system has not been designed to support this use so there are maybe isolation issues.
In fact, in the PIM, the "batch:job" command is always run through a new system process (cf SimpleJobLauncher), I think in your case the main problem come from running twice in the same process.
I would take a look in Akeneo\Bundle\BatchBundle\Command\BatchCommand and Akeneo\Bundle\BatchBundle\EventListener\LoggerSubscriber, duplicate logs means both executions use the same JobExecution or StepExecutions instances.
Do you run the same JobInstance twice in your wrapper command? (ex: "akeneo:batch:job csv_product_import").
I'm interested to know more precisely your use case, you need to run a first import then a second one once the first is done?
Hello @nidup, thanks for reply.
Do you run the same JobInstance twice in your wrapper command?
No, I run different job instances (e.g. csv_product_import1 and csv_product_import2).
I'm interested to know more precisely your use case, you need to run a first import then a second one once the first is done?
Yes, this is exactly what I need.
According to partial review of Akeneo\Bundle\BatchBundle\Command\BatchCommand it looks like each command runs with different instances by passed job code, and doesn't share any context.
Regards, Viktor & Alexandr.
@NovikovViktor See http://jmsyst.com/bundles/JMSJobQueueBundle/master/usage
<?php
$job = new Job('a');
$dependentJob = new Job('b');
$dependentJob->addDependency($job);
$em->persist($job);
$em->persist($dependentJob);
$em->flush();
I think it is what you need.
Hello @a2xchip , thanks for the advice I will take this bundle into consideration. For now I achieved goal by using Symfony Process component just run second command in separate process.
Regards, Viktor.
Hi @NovikovViktor !
Is this issue resolved ? :)
@pierallard
Sorry for the long-term answer. Yes, this issue is resolved, so I mark it as Closed.