Log and output all error occured during last cron run
[MAILPOET-2017]
This commit is contained in:
@@ -10,6 +10,22 @@ const CronStatus = (props) => {
|
|||||||
active: MailPoet.I18n.t('running'),
|
active: MailPoet.I18n.t('running'),
|
||||||
inactive: MailPoet.I18n.t('cronWaiting'),
|
inactive: MailPoet.I18n.t('cronWaiting'),
|
||||||
};
|
};
|
||||||
|
const lastError = Array.isArray(status.last_error)
|
||||||
|
? (
|
||||||
|
<>
|
||||||
|
{
|
||||||
|
status.last_error.map(error => (
|
||||||
|
<div key={error.worker}>
|
||||||
|
{error.worker}
|
||||||
|
:
|
||||||
|
{' '}
|
||||||
|
<i>{error.message}</i>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
: status.last_error;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h2>{MailPoet.I18n.t('systemStatusCronStatusTitle')}</h2>
|
<h2>{MailPoet.I18n.t('systemStatusCronStatusTitle')}</h2>
|
||||||
@@ -38,7 +54,7 @@ const CronStatus = (props) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: MailPoet.I18n.t('lastSeenError'),
|
key: MailPoet.I18n.t('lastSeenError'),
|
||||||
value: status.last_error || MailPoet.I18n.t('none'),
|
value: lastError || MailPoet.I18n.t('none'),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
@@ -25,14 +25,23 @@ class Daemon {
|
|||||||
$settings_daemon_data['run_started_at'] = time();
|
$settings_daemon_data['run_started_at'] = time();
|
||||||
CronHelper::saveDaemon($settings_daemon_data);
|
CronHelper::saveDaemon($settings_daemon_data);
|
||||||
|
|
||||||
|
$errors = [];
|
||||||
foreach ($this->getWorkers() as $worker) {
|
foreach ($this->getWorkers() as $worker) {
|
||||||
try {
|
try {
|
||||||
$worker->process();
|
$worker->process();
|
||||||
} catch (\Exception $e) {
|
} 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
|
// Log successful execution
|
||||||
CronHelper::saveDaemonRunCompleted(time());
|
CronHelper::saveDaemonRunCompleted(time());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user