BUGFIX: slow jobs without runs trigger timeouts

This commit is contained in:
Jeroen De Meerleer 2021-08-02 10:54:50 +02:00
parent 0b6a2a0c8c
commit cc54616d7b
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
1 changed files with 2 additions and 1 deletions

View File

@ -242,7 +242,8 @@ class Job extends Repository
public function runNow($job, $console = false) {
$job = $this->getJob($job, true);
$runRepo = new Run($this->dbcon);
if($console == false && ($runRepo->isSlowJob($job['id']) || $job['data']['crontype'] === 'reboot')) {
if($console == false && ($runRepo->isSlowJob($job['id']) || count($runRepo->getRunsForJob($job['id'])) == 0 || $job['data']['crontype'] === 'reboot')) {
$jobsSql = "UPDATE job SET running = :status WHERE id = :id AND running IN (0,1,2)";
$jobsStmt = $this->dbcon->prepare($jobsSql);
$jobsStmt->executeQuery([':id' => $job['id'], ':status' => 2]);