BUGFIX: when rebooting via cli one could possibly not recover

This commit is contained in:
Jeroen De Meerleer 2021-07-15 14:29:47 +02:00
parent f8c89230b7
commit f49e9e06a7
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
2 changed files with 9 additions and 2 deletions

View File

@ -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);

View File

@ -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']);