Log and output all error occured during last cron run

[MAILPOET-2017]
This commit is contained in:
Jan Jakeš
2019-04-30 16:55:29 +02:00
committed by M. Shull
parent 0fa5146146
commit 0a1b475ffd
2 changed files with 27 additions and 2 deletions

View File

@@ -25,14 +25,23 @@ class Daemon {
$settings_daemon_data['run_started_at'] = time();
CronHelper::saveDaemon($settings_daemon_data);
$errors = [];
foreach ($this->getWorkers() as $worker) {
try {
$worker->process();
} catch (\Exception $e) {
CronHelper::saveDaemonLastError($e->getMessage());
$worker_class_name_parts = explode('\\', get_class($worker));
$errors[] = [
'worker' => end($worker_class_name_parts),
'message' => $e->getMessage(),
];
}
}
if (!empty($errors)) {
CronHelper::saveDaemonLastError($errors);
}
// Log successful execution
CronHelper::saveDaemonRunCompleted(time());
}