Reimplemented periodic check
This commit is contained in:
parent
cec29bb426
commit
3d5863e77a
|
@ -86,7 +86,11 @@ class DaemonCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->doctrine->getManager()->clear();
|
$this->doctrine->getManager()->clear();
|
||||||
sleep(1);
|
|
||||||
|
$maxwait = time() + 30;
|
||||||
|
$nextrun = $jobRepo->getTimeOfNextRun();
|
||||||
|
$sleepuntil = min($maxwait, $nextrun);
|
||||||
|
if($sleepuntil > time()) time_sleep_until($sleepuntil);
|
||||||
}
|
}
|
||||||
$output->writeln('Ended after ' . $timelimit . ' seconds');
|
$output->writeln('Ended after ' . $timelimit . ' seconds');
|
||||||
pcntl_wait($status);
|
pcntl_wait($status);
|
||||||
|
|
|
@ -589,6 +589,37 @@ class JobRepository extends EntityRepository
|
||||||
return ['success' => true, 'message' => 'Cronjob succesfully edited'];
|
return ['success' => true, 'message' => 'Cronjob succesfully edited'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTimeOfNextRun()
|
||||||
|
{
|
||||||
|
if(!empty($this->getJobsDue())) return time();
|
||||||
|
|
||||||
|
$qb = $this->createQueryBuilder('job');
|
||||||
|
$firstScheduledJob = $qb
|
||||||
|
->where('job.running = 0')
|
||||||
|
->orderBy('job.nextrun')
|
||||||
|
->getQuery()->getResult();
|
||||||
|
|
||||||
|
$firstRebootJob = $qb
|
||||||
|
->where('job.running > 2')
|
||||||
|
->orderBy('job.running')
|
||||||
|
->getQuery()->getResult();
|
||||||
|
|
||||||
|
|
||||||
|
if(empty($firstScheduledJob)) {
|
||||||
|
$val1 = PHP_INT_MAX;
|
||||||
|
} else {
|
||||||
|
$val1 = $firstScheduledJob[0]->getNextRun();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(empty($firstRebootJob)) {
|
||||||
|
$val2 = PHP_INT_MAX;
|
||||||
|
} else {
|
||||||
|
$val2 = $firstRebootJob[0]->getRunning();
|
||||||
|
}
|
||||||
|
|
||||||
|
return min($val1, $val2);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $values
|
* @param array $values
|
||||||
* @param Job|null $job
|
* @param Job|null $job
|
||||||
|
|
Loading…
Reference in New Issue