Skip to content

Commit

Permalink
Fixes serial fluctuation in the timing plot
Browse files Browse the repository at this point in the history
  • Loading branch information
vtsykun committed Oct 6, 2018
1 parent de921e4 commit 32b8a11
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Command/CronStatRetrieveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
// For BC with Symfony 2.8
$maxAttempts = 10;
$lock = new LockHandler('okvpn_mq_stat');
while ($maxAttempts--) {
if (true === $lock->lock()) {
break;
}
sleep(1);
}

if (!$lock->lock()) {
$output->writeln('Aborting, another of the same command is still active');
return;
Expand All @@ -54,7 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
sleep(5);

try {
$lifetime = $input->getOption('lifetime') - 2 * QueuedMessagesProvider::POLLING_TIME;
$lifetime = $input->getOption('lifetime');
$startTime = time();
$delayPool = new DelayPool();
$delayPool->setLogger(new ConsoleLogger($output));
Expand All @@ -70,7 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'processCount'
);

while (time() - $startTime < $lifetime) {
while (time() - $startTime <= $lifetime) {
$delayPool->sync();
sleep(1);
}
Expand Down

0 comments on commit 32b8a11

Please sign in to comment.