reformat: fix codestyle
This commit is contained in:
@@ -170,9 +170,9 @@ class SettingsHandler
|
|||||||
// For now, let's use global retrieval via cache if possible, or assume it's injected.
|
// For now, let's use global retrieval via cache if possible, or assume it's injected.
|
||||||
// But wait, getLastCronRunDate logic was in controller.
|
// But wait, getLastCronRunDate logic was in controller.
|
||||||
// SchedulerService stores last run in cache. We have $this->cache here.
|
// SchedulerService stores last run in cache. We have $this->cache here.
|
||||||
|
|
||||||
$lastRunTimestamp = $this->cache->get("scheduler.global_last_run");
|
$lastRunTimestamp = $this->cache->get("scheduler.global_last_run");
|
||||||
|
|
||||||
if ($lastRunTimestamp) {
|
if ($lastRunTimestamp) {
|
||||||
return date('d.m.Y H:i:s', (int)$lastRunTimestamp);
|
return date('d.m.Y H:i:s', (int)$lastRunTimestamp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,4 +37,3 @@ class ScheduleJobRegistry
|
|||||||
return $this->jobs;
|
return $this->jobs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,4 +41,3 @@ class SchedulerResult
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class SchedulerService
|
|||||||
$this->acquireGlobalLock();
|
$this->acquireGlobalLock();
|
||||||
// Since we want to run every 5 minutes, running it more frequently won't trigger jobs earlier than due,
|
// Since we want to run every 5 minutes, running it more frequently won't trigger jobs earlier than due,
|
||||||
// but locking might prevent overlap if previous run takes > 5 mins.
|
// but locking might prevent overlap if previous run takes > 5 mins.
|
||||||
// However, updating global last run on every attempt might be useful for diagnostics,
|
// However, updating global last run on every attempt might be useful for diagnostics,
|
||||||
// but strictly speaking, we only care if tasks were processed.
|
// but strictly speaking, we only care if tasks were processed.
|
||||||
$this->updateGlobalLastRun();
|
$this->updateGlobalLastRun();
|
||||||
|
|
||||||
@@ -105,10 +105,9 @@ class SchedulerService
|
|||||||
|
|
||||||
$duration = microtime(true) - $startTime;
|
$duration = microtime(true) - $startTime;
|
||||||
$this->updateLastRun($id);
|
$this->updateLastRun($id);
|
||||||
|
|
||||||
$this->logger->info("Job executed: {$name}", ['duration' => $duration]);
|
$this->logger->info("Job executed: {$name}", ['duration' => $duration]);
|
||||||
$result->addExecuted($name, $duration);
|
$result->addExecuted($name, $duration);
|
||||||
|
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
$this->updateLastFailure($id, $e->getMessage());
|
$this->updateLastFailure($id, $e->getMessage());
|
||||||
$this->logger->error("Job failed: {$name}", ['exception' => $e]);
|
$this->logger->error("Job failed: {$name}", ['exception' => $e]);
|
||||||
@@ -116,7 +115,6 @@ class SchedulerService
|
|||||||
} finally {
|
} finally {
|
||||||
$this->unlockJob($id);
|
$this->unlockJob($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
$this->logger->error("Error processing job {$name}: " . $e->getMessage());
|
$this->logger->error("Error processing job {$name}: " . $e->getMessage());
|
||||||
$result->addFailed($name, 'Processing error: ' . $e->getMessage());
|
$result->addFailed($name, 'Processing error: ' . $e->getMessage());
|
||||||
@@ -146,7 +144,7 @@ class SchedulerService
|
|||||||
private function lockJob(string $id): void
|
private function lockJob(string $id): void
|
||||||
{
|
{
|
||||||
// 30 minutes max execution time for a single job safe-guard
|
// 30 minutes max execution time for a single job safe-guard
|
||||||
$this->cache->set("scheduler.lock.{$id}", 1, 1800);
|
$this->cache->set("scheduler.lock.{$id}", 1, 1800);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function unlockJob(string $id): void
|
private function unlockJob(string $id): void
|
||||||
@@ -163,7 +161,7 @@ class SchedulerService
|
|||||||
|
|
||||||
$lastRunDate = (new DateTime())->setTimestamp((int)$lastRun);
|
$lastRunDate = (new DateTime())->setTimestamp((int)$lastRun);
|
||||||
$now = new DateTime();
|
$now = new DateTime();
|
||||||
|
|
||||||
return $lastRunDate->format('Y-m-d H:i') === $now->format('Y-m-d H:i');
|
return $lastRunDate->format('Y-m-d H:i') === $now->format('Y-m-d H:i');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,4 +6,3 @@ interface TaskInterface
|
|||||||
{
|
{
|
||||||
public function execute(): void;
|
public function execute(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ parameters:
|
|||||||
- src
|
- src
|
||||||
- bastion
|
- bastion
|
||||||
- framework
|
- framework
|
||||||
|
- console
|
||||||
|
|
||||||
scanDirectories:
|
scanDirectories:
|
||||||
- stubs
|
- stubs
|
||||||
|
|||||||
Reference in New Issue
Block a user