diff options
author | Simon Rettberg | 2017-05-12 22:49:08 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-05-12 22:49:08 +0200 |
commit | d7c92f2c39a91ceb9de65f6312205ba15210a91d (patch) | |
tree | dfef70b1719c530b3d767b4300d614565dd5daa2 /apis | |
parent | [apis/cron] Add crash logging functionality (diff) | |
download | slx-admin-d7c92f2c39a91ceb9de65f6312205ba15210a91d.tar.gz slx-admin-d7c92f2c39a91ceb9de65f6312205ba15210a91d.tar.xz slx-admin-d7c92f2c39a91ceb9de65f6312205ba15210a91d.zip |
[apis/cron] Fix typo in 'EventLog' handle blocked jobs in separate list
Diffstat (limited to 'apis')
-rw-r--r-- | apis/cron.inc.php | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/apis/cron.inc.php b/apis/cron.inc.php index 48e50a94..b727b21f 100644 --- a/apis/cron.inc.php +++ b/apis/cron.inc.php @@ -11,6 +11,7 @@ if (!isLocalExecution()) exit(0); define('CRON_KEY_STATUS', 'cron.key.status'); +define('CRON_KEY_BLOCKED', 'cron.key.blocked'); // Crash report mode - used by system crontab entry if (($report = Request::get('crashreport', false, 'string'))) { @@ -23,17 +24,26 @@ if (($report = Request::get('crashreport', false, 'string'))) { foreach ($list as $item) { Property::removeFromList(CRON_KEY_STATUS, $item); $entry = explode('|', $item, 2); - if (count($entry) !== 2 || time() - $entry[1] > 3600) + if (count($entry) !== 2) continue; - $str[] = $item[0] . ' (started ' . (time() - $entry[1]) . 's ago)'; + $time = time() - $entry[1]; + if ($time > 3600) // Sanity check + continue; + $str[] = $entry[0] . ' (started ' . $time . 's ago)'; + Property::addToList(CRON_KEY_BLOCKED, $entry[0], 1800); + } + if (empty($str)) { + $str = 'an unknown module'; } $message = 'Conjob failed. No reply by ' . implode(', ', $str); $details = ''; if (is_readable($report)) { $details = file_get_contents($report); - $message .=', see details for log'; + if (!empty($details)) { + $message .=', click "details" for log'; + } } - EvenLog::failure($message, $details); + EventLog::failure($message, $details); exit(0); } @@ -57,6 +67,7 @@ function handleModule($file) include_once $file; } +$blocked = Property::getList(CRON_KEY_BLOCKED); foreach (Hook::load('cron') as $hook) { // Check if job is still running, or should be considered crashed $status = getJobStatus($hook->moduleId); @@ -75,6 +86,10 @@ foreach (Hook::load('cron') as $hook) { continue; } } + // Are we blocked + if (in_array($hook->moduleId, $blocked)) + continue; + // Fire away $value = $hook->moduleId . '|' . time(); Property::addToList(CRON_KEY_STATUS, $value, 1800); try { |