[TikiWiki-commits] [Git][tikiwiki/tiki][master] [EHN] Scheduler: notify for failed tasks
Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <68b882b9b55a3_2cdd0902827@gitlab-sidekiq-low-urgency-cpu-bound-v2-5db85b5f7d-t8vl6.mail> |
Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
ea7c1a6a by Josaphat Imani at 2025-09-03T17:54:40+00:00
[EHN] Scheduler: notify for failed tasks
---
* Use hailed/stalled users as users to notify on failure
* [EHN] Scheduler: notify for failed tasks
See merge request tikiwiki/tiki!8000
- - - - -
5 changed files:
- lib/core/Notifications/Email.php
- lib/core/Scheduler/Manager.php
- lib/prefs/scheduler.php
- + templates/mail/scheduler_failed_notification.tpl
- + templates/mail/scheduler_failed_notification_subject.tpl
Changes:
=====================================
lib/core/Notifications/Email.php
=====================================
@@ -75,7 +75,7 @@ class Email
* @return int The number of sent emails
* @throws \Exception
*/
- public static function sendSchedulerNotification($subjectTpl, $txtTpl, $scheduler, $usersToNotify = [])
+ public static function sendSchedulerNotification($subjectTpl, $txtTpl, $scheduler, $usersToNotify = [], $customMessage = '')
{
global $prefs, $tikipath;
@@ -89,6 +89,7 @@ class Email
$smarty->assign('webroot', $tikipath);
$smarty->assign('stalledTimeout', $tikilib->get_preference('scheduler_stalled_timeout'));
$smarty->assign('healingTimeout', $tikilib->get_preference('scheduler_healing_timeout'));
+ $smarty->assign('customMessage', $customMessage);
$defaultLang = $prefs['site_language'];
$watchList = array_map(function ($user) use ($defaultLang) {
=====================================
lib/core/Scheduler/Manager.php
=====================================
@@ -127,6 +127,11 @@ class Scheduler_Manager
if ($result['status'] == 'failed') {
$this->logger->error(sprintf(tra("***** Scheduler %s - FAILED *****\n%s"), $schedulerTask->name, $result['message']));
+ if ($tikilib->get_preference('scheduler_notify_on_stalled', 'y')) {
+ $users = Scheduler_Utils::getSchedulerNotificationUsers('scheduler_users_to_notify_on_healed');
+
+ Tiki\Notifications\Email::sendSchedulerNotification('scheduler_failed_notification_subject.tpl', 'scheduler_failed_notification.tpl', $this, $users, $result['message']);
+ }
} else {
$this->logger->notice(sprintf(tra("***** Scheduler %s - OK *****"), $schedulerTask->name));
}
=====================================
lib/prefs/scheduler.php
=====================================
@@ -16,8 +16,8 @@ function prefs_scheduler_list($partial = false)
'tags' => ['advanced'],
],
'scheduler_notify_on_stalled' => [
- 'name' => tr('Notify on stalled and healed schedulers'),
- 'description' => tr('Send an email notification when a stalled scheduler is detected or healed.'),
+ 'name' => tr('Notify on stalled, healed and failed schedulers'),
+ 'description' => tr('Send an email notification when a stalled, healed or failed scheduler is detected.'),
'type' => 'flag',
'default' => 'y',
'tags' => ['advanced'],
@@ -30,8 +30,8 @@ function prefs_scheduler_list($partial = false)
'tags' => ['advanced'],
],
'scheduler_users_to_notify_on_stalled' => [
- 'name' => tr('Users to notify on stalled and healed tasks'),
- 'description' => tr('List of users/emails separated by comma to be notified when a scheduler task is stalled or healed.</br><code>Ex: admin,[email protected]</code></br><strong>If empty and "Notify admins" is checked, notifications will be sent to all administrators.</strong>'),
+ 'name' => tr('Users to notify on stalled, healed and failed tasks'),
+ 'description' => tr('List of users/emails separated by comma to be notified when a scheduler task is stalled, healed, or failed.</br><code>Ex: admin,[email protected]</code></br><strong>If empty and "Notify admins" is checked, notifications will be sent to all administrators.</strong>'),
'type' => 'text',
'default' => '',
'tags' => ['advanced'],
=====================================
templates/mail/scheduler_failed_notification.tpl
=====================================
@@ -0,0 +1,13 @@
+{tr}Warning{/tr}
+
+{tr _0=$schedulerName _1=$healingTimeout}Scheduler "%0" has failed.{/tr}
+
+
+{tr}Details{/tr}
+{tr}Reason:{/tr} {$customMessage}
+{tr}Site Name:{/tr} {$siteName}
+{if !empty($siteUrl)}
+ {tr}Site URL:{/tr} {$siteUrl}
+{/if}
+{tr}Server:{/tr} {$server}
+{tr}Webroot:{/tr} {$webroot}
=====================================
templates/mail/scheduler_failed_notification_subject.tpl
=====================================
@@ -0,0 +1 @@
+{tr _0=$siteName _1=$schedulerName}[%0] Scheduler "%1" failed{/tr}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/ea7c1a6a7a23bd3ef8facd10b4bdebabea2ebfbc
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/ea7c1a6a7a23bd3ef8facd10b4bdebabea2ebfbc
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs