summaryrefslogtreecommitdiffstats
path: root/apis
diff options
context:
space:
mode:
authorSimon Rettberg2017-05-12 17:10:46 +0200
committerSimon Rettberg2017-05-12 17:10:46 +0200
commitdbedb7285f9002eee9a0ad0a7b57937f60010874 (patch)
treec4695fac64e58ebc5d1ec6f8e49df3a997c35d53 /apis
parentAPI: Put parameters into $_GET in cli-mode (diff)
downloadslx-admin-dbedb7285f9002eee9a0ad0a7b57937f60010874.tar.gz
slx-admin-dbedb7285f9002eee9a0ad0a7b57937f60010874.tar.xz
slx-admin-dbedb7285f9002eee9a0ad0a7b57937f60010874.zip
[apis/cron] Add crash logging functionality
Diffstat (limited to 'apis')
-rw-r--r--apis/cron.inc.php27
1 files changed, 26 insertions, 1 deletions
diff --git a/apis/cron.inc.php b/apis/cron.inc.php
index cf96ac29..48e50a94 100644
--- a/apis/cron.inc.php
+++ b/apis/cron.inc.php
@@ -12,6 +12,31 @@ if (!isLocalExecution())
define('CRON_KEY_STATUS', 'cron.key.status');
+// Crash report mode - used by system crontab entry
+if (($report = Request::get('crashreport', false, 'string'))) {
+ $list = Property::getList(CRON_KEY_STATUS);
+ if (empty($list)) {
+ error_log('Cron crashreport triggered but no cronjob marked active.');
+ exit(0);
+ }
+ $str = array();
+ foreach ($list as $item) {
+ Property::removeFromList(CRON_KEY_STATUS, $item);
+ $entry = explode('|', $item, 2);
+ if (count($entry) !== 2 || time() - $entry[1] > 3600)
+ continue;
+ $str[] = $item[0] . ' (started ' . (time() - $entry[1]) . 's ago)';
+ }
+ $message = 'Conjob failed. No reply by ' . implode(', ', $str);
+ $details = '';
+ if (is_readable($report)) {
+ $details = file_get_contents($report);
+ $message .=', see details for log';
+ }
+ EvenLog::failure($message, $details);
+ exit(0);
+}
+
function getJobStatus($id)
{
// Re fetch from D on every call as some jobs could take longer
@@ -46,7 +71,7 @@ foreach (Hook::load('cron') as $hook) {
} else {
// Consider job crashed
Property::removeFromList(CRON_KEY_STATUS, $status['string']);
- EventLog::failure('Cronjob for module ' . $hook->moduleId . ' seems to be stuck or has crashed. Check the php or web server error log.');
+ EventLog::failure('Cronjob for module ' . $hook->moduleId . ' seems to be stuck or has crashed.');
continue;
}
}