From f49e9e06a7f1f0b8fa7097cd7250655de9fe4fc7 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Thu, 15 Jul 2021 14:29:47 +0200 Subject: [PATCH] BUGFIX: when rebooting via cli one could possibly not recover --- src/Command/DaemonCommand.php | 9 ++++++++- src/Command/RunCommand.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Command/DaemonCommand.php b/src/Command/DaemonCommand.php index 0a1ce9f..a1f937e 100644 --- a/src/Command/DaemonCommand.php +++ b/src/Command/DaemonCommand.php @@ -49,7 +49,14 @@ class DaemonCommand extends Command $jobsToRun = $jobRepo->getJobsDue(); if(!empty($jobsToRun)) { foreach($jobsToRun as $job) { - if($jobRepo->getTempVar($job['id'], 'consolerun')) continue; + $jobObj = $jobRepo->getJob($job['id']); + if($jobObj['data']['crontype'] == 'reboot') { + $str = @file_get_contents('/proc/uptime'); + $num = floatval($str); + $rebootedself = ($num < $jobObj['data']['reboot-duration'] * 60); + $consolerun = $jobRepo->getTempVar($job['id'], 'consolerun'); + if($consolerun && !$rebootedself) continue; + } $jobRepo->setJobRunning($job['id'], true); $output->writeln('Running Job ' . $job['id']); declare(ticks = 1); diff --git a/src/Command/RunCommand.php b/src/Command/RunCommand.php index f53dfe1..596a9b4 100644 --- a/src/Command/RunCommand.php +++ b/src/Command/RunCommand.php @@ -56,7 +56,7 @@ class RunCommand extends Command $jobRepo->setTempVar($jobId, 'consolerun', false); $output->write($result['output']); if($result['success']) { - $output->writeln('Job succeeded with in ' . number_format($result['runtime'], 3) . 'secs exitcode ' . $result['exitcode']); + $output->writeln('Job succeeded with in ' . number_format($result['runtime'], 3) . 'secs with exitcode ' . $result['exitcode']); return Command::SUCCESS; } else { $output->writeln('Job failed in ' . number_format($result['runtime'], 3) . 'secs with exitcode ' . $result['exitcode']);