first commit
This commit is contained in:
39
bundles/External/VarioBundle/Command/DelayedUpdateCommand.php
vendored
Normal file
39
bundles/External/VarioBundle/Command/DelayedUpdateCommand.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace External\VarioBundle\Command;
|
||||
|
||||
use External\VarioBundle\Util\VarioDelayedUpdate;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class DelayedUpdateCommand extends Command
|
||||
{
|
||||
protected static $defaultName = 'vario:delayed_update';
|
||||
|
||||
/** @var VarioDelayedUpdate */
|
||||
private $varioDelayedUpdate;
|
||||
|
||||
/** @required */
|
||||
public function setVarioDelayedUpdate(VarioDelayedUpdate $varioDelayedUpdate): void
|
||||
{
|
||||
$this->varioDelayedUpdate = $varioDelayedUpdate;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
while (true) {
|
||||
sqlGetConnection()->connect();
|
||||
|
||||
$output->writeln('Processing batch of 100 items...');
|
||||
$processed = $this->varioDelayedUpdate->processDelayedUpdate(100);
|
||||
if ($processed <= 0) {
|
||||
$output->writeln('Nothing to process, sleeping for 300 seconds...');
|
||||
sqlGetConnection()->close();
|
||||
sleep(300);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user