Skip to content

Commit

Permalink
Support multiple daily process locking backends with distributed poll…
Browse files Browse the repository at this point in the history
…ing (librenms#11896)

* Implement locks in the file cache

* Replace custom locks

* implement restore lock
Used when re-hydrating

* remove legacy use statements

* Add class descriptions

* Fix style

* Default to database cache driver

* missed cache_locks table
prevent chicken-egg issue

* style fixes

* Remove custom file lock implementation

* missed items from file cache

* Update schema definition
hmm, other schema noise must be from manual modification as this is generated from a freshly migrated db.

* require predis, it is pure python, so no harm in adding

* and set predis as the default client
  • Loading branch information
murrant authored Oct 7, 2020
1 parent e52531f commit 1e4702f
Show file tree
Hide file tree
Showing 17 changed files with 235 additions and 560 deletions.
58 changes: 0 additions & 58 deletions LibreNMS/Interfaces/Lock.php

This file was deleted.

134 changes: 0 additions & 134 deletions LibreNMS/Util/FileLock.php

This file was deleted.

145 changes: 0 additions & 145 deletions LibreNMS/Util/MemcacheLock.php

This file was deleted.

34 changes: 16 additions & 18 deletions alerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,30 @@
*/

use LibreNMS\Alert\RunAlerts;
use LibreNMS\Util\FileLock;

$init_modules = ['alerts', 'laravel'];
require __DIR__ . '/includes/init.php';

$options = getopt('d::');

$alerts_lock = FileLock::lockOrDie('alerts');

$alerts = new RunAlerts();

if (set_debug(isset($options['d']))) {
echo "DEBUG!\n";
}

if (! defined('TEST') && \LibreNMS\Config::get('alert.disable') != 'true') {
echo 'Start: ' . date('r') . "\r\n";
echo 'ClearStaleAlerts():' . PHP_EOL;
$alerts->clearStaleAlerts();
echo "RunFollowUp():\r\n";
$alerts->runFollowUp();
echo "RunAlerts():\r\n";
$alerts->runAlerts();
echo "RunAcks():\r\n";
$alerts->runAcks();
echo 'End : ' . date('r') . "\r\n";
$alerts_lock = Cache::lock('alerts');
if ($alerts_lock->get()) {
$alerts = new RunAlerts();
if (! defined('TEST') && \LibreNMS\Config::get('alert.disable') != 'true') {
echo 'Start: ' . date('r') . "\r\n";
echo 'ClearStaleAlerts():' . PHP_EOL;
$alerts->clearStaleAlerts();
echo "RunFollowUp():\r\n";
$alerts->runFollowUp();
echo "RunAlerts():\r\n";
$alerts->runAlerts();
echo "RunAcks():\r\n";
$alerts->runAcks();
echo 'End : ' . date('r') . "\r\n";
}
$alerts_lock->release();
}

$alerts_lock->release();
Loading

0 comments on commit 1e4702f

Please sign in to comment.