BUGFIX: when querying the database pointer could be reused
This commit is contained in:
parent
3a95d23d8b
commit
3a48fd7e52
|
@ -56,7 +56,7 @@ class DaemonCommand extends Command
|
|||
|
||||
$jobsToRun = $jobRepo->getJobsDue();
|
||||
if(!empty($jobsToRun)) {
|
||||
foreach($jobsToRun as $job) {
|
||||
foreach($jobsToRun as $key=>$job) {
|
||||
if($job->getData('crontype') == 'reboot') {
|
||||
$str = @file_get_contents('/proc/uptime');
|
||||
$num = floatval($str);
|
||||
|
@ -83,6 +83,8 @@ class DaemonCommand extends Command
|
|||
$jobRepo->setJobRunning($job, false);
|
||||
exit;
|
||||
}
|
||||
unset($jobsToRun[$key]);
|
||||
unset($job);
|
||||
}
|
||||
}
|
||||
$this->doctrine->getManager()->clear();
|
||||
|
@ -92,6 +94,7 @@ class DaemonCommand extends Command
|
|||
$nextrun = max($jobRepo->getTimeOfNextRun(), time() + 1);
|
||||
$sleepuntil = min($maxwait, $nextrun);
|
||||
if($sleepuntil > time()) time_sleep_until($sleepuntil);
|
||||
gc_collect_cycles();
|
||||
}
|
||||
$output->writeln('Ended after ' . $timelimit . ' seconds');
|
||||
pcntl_wait($status);
|
||||
|
|
|
@ -14,7 +14,6 @@ use GuzzleHttp\Exception\GuzzleException;
|
|||
use phpseclib3\Crypt\PublicKeyLoader;
|
||||
use phpseclib3\Net\SSH2;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -108,6 +107,7 @@ class JobRepository extends EntityRepository
|
|||
*/
|
||||
public function getJobsDue(): array
|
||||
{
|
||||
$this->getEntityManager()->clear();
|
||||
$qb = $this->createQueryBuilder('job');
|
||||
return $qb
|
||||
->where(
|
||||
|
|
Loading…
Reference in New Issue