|
29 | 29 | $monitoring->endCronjob($cron_name, 'E0009', 0, true, false); |
30 | 30 | } |
31 | 31 |
|
32 | | -$log->logDebug(" IDLE Worker Notifications ..."); |
33 | | -// Find all IDLE workers |
34 | | -$aWorkers = $worker->getAllIdleWorkers(); |
35 | | -if (empty($aWorkers)) { |
36 | | - $log->logDebug(" no idle workers found"); |
37 | | -} else { |
38 | | - $log->logInfo(" found " . count($aWorkers) . " IDLE workers"); |
39 | | - foreach ($aWorkers as $aWorker) { |
40 | | - $aData = $aWorker; |
41 | | - $aData['username'] = $user->getUserName($aWorker['account_id']); |
42 | | - $aData['subject'] = 'IDLE Worker : ' . $aWorker['username']; |
43 | | - $aData['worker'] = $aWorker['username']; |
44 | | - $aData['email'] = $user->getUserEmail($aData['username']); |
45 | | - $log->logDebug(" " . $aWorker['username'] . "..."); |
46 | | - if (!$notification->sendNotification($aWorker['account_id'], 'idle_worker', $aData)) |
47 | | - $log->logDebug(" Failed sending notifications: " . $notification->getCronError()); |
| 32 | +if ($setting->getValue('notifications_disable_idle_worker') != 1) { |
| 33 | + $log->logDebug(" IDLE Worker Notifications ..."); |
| 34 | + // Find all IDLE workers |
| 35 | + $aWorkers = $worker->getAllIdleWorkers(); |
| 36 | + if (empty($aWorkers)) { |
| 37 | + $log->logDebug(" no idle workers found"); |
| 38 | + } else { |
| 39 | + $log->logInfo(" found " . count($aWorkers) . " IDLE workers"); |
| 40 | + foreach ($aWorkers as $aWorker) { |
| 41 | + $aData = $aWorker; |
| 42 | + $aData['username'] = $user->getUserName($aWorker['account_id']); |
| 43 | + $aData['subject'] = 'IDLE Worker : ' . $aWorker['username']; |
| 44 | + $aData['worker'] = $aWorker['username']; |
| 45 | + $aData['email'] = $user->getUserEmail($aData['username']); |
| 46 | + $log->logDebug(" " . $aWorker['username'] . "..."); |
| 47 | + if (!$notification->sendNotification($aWorker['account_id'], 'idle_worker', $aData)) |
| 48 | + $log->logDebug(" Failed sending notifications: " . $notification->getCronError()); |
| 49 | + } |
48 | 50 | } |
49 | | -} |
50 | 51 |
|
51 | 52 |
|
52 | | -$log->logDebug(" Reset IDLE Worker Notifications ..."); |
53 | | -// We notified, lets check which recovered |
54 | | -$aNotifications = $notification->getAllActive('idle_worker'); |
55 | | -if (!empty($aNotifications)) { |
56 | | - $log->logInfo(" found " . count($aNotifications) . " active notification(s)"); |
57 | | - foreach ($aNotifications as $aNotification) { |
58 | | - $aData = json_decode($aNotification['data'], true); |
59 | | - $aWorker = $worker->getWorker($aData['id']); |
60 | | - $log->logDebug(" " . $aWorker['username'] . " ..."); |
61 | | - if ($aWorker['hashrate'] > 0) { |
62 | | - if ($notification->setInactive($aNotification['id'])) { |
63 | | - $log->logDebug(" updated #" . $aNotification['id'] . " for " . $aWorker['username'] . " as inactive"); |
| 53 | + $log->logDebug(" Reset IDLE Worker Notifications ..."); |
| 54 | + // We notified, lets check which recovered |
| 55 | + $aNotifications = $notification->getAllActive('idle_worker'); |
| 56 | + if (!empty($aNotifications)) { |
| 57 | + $log->logInfo(" found " . count($aNotifications) . " active notification(s)"); |
| 58 | + foreach ($aNotifications as $aNotification) { |
| 59 | + $aData = json_decode($aNotification['data'], true); |
| 60 | + $aWorker = $worker->getWorker($aData['id']); |
| 61 | + $log->logDebug(" " . $aWorker['username'] . " ..."); |
| 62 | + if ($aWorker['hashrate'] > 0) { |
| 63 | + if ($notification->setInactive($aNotification['id'])) { |
| 64 | + $log->logDebug(" updated #" . $aNotification['id'] . " for " . $aWorker['username'] . " as inactive"); |
| 65 | + } else { |
| 66 | + $log->logError(" failed to update #" . $aNotification['id'] . " for " . $aWorker['username']); |
| 67 | + } |
64 | 68 | } else { |
65 | | - $log->logError(" failed to update #" . $aNotification['id'] . " for " . $aWorker['username']); |
| 69 | + $log->logDebug(" still inactive"); |
66 | 70 | } |
67 | | - } else { |
68 | | - $log->logDebug(" still inactive"); |
69 | 71 | } |
| 72 | + } else { |
| 73 | + $log->logDebug(" no active IDLE worker notifications"); |
70 | 74 | } |
71 | | -} else { |
72 | | - $log->logDebug(" no active IDLE worker notifications"); |
73 | 75 | } |
74 | 76 |
|
75 | 77 | require_once('cron_end.inc.php'); |
|
0 commit comments