mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Support multiple daily process locking backends with distributed polling (#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
This commit is contained in:
@@ -23,12 +23,6 @@
|
||||
* @copyright 2017-2018 Tony Murray
|
||||
* @author Tony Murray <[email protected]>
|
||||
*/
|
||||
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\Exceptions\LockException;
|
||||
use LibreNMS\Util\FileLock;
|
||||
use LibreNMS\Util\MemcacheLock;
|
||||
|
||||
if (! isset($init_modules) && php_sapi_name() == 'cli') {
|
||||
// Not called from within discovery, let's load up the necessary stuff.
|
||||
$init_modules = [];
|
||||
@@ -37,15 +31,13 @@ if (! isset($init_modules) && php_sapi_name() == 'cli') {
|
||||
|
||||
$return = 0;
|
||||
|
||||
try {
|
||||
if (isset($skip_schema_lock) && ! $skip_schema_lock) {
|
||||
if (Config::get('distributed_poller')) {
|
||||
$schemaLock = MemcacheLock::lock('schema', 30, 86000);
|
||||
} else {
|
||||
$schemaLock = FileLock::lock('schema', 30);
|
||||
}
|
||||
}
|
||||
// make sure the cache_locks table exists before attempting to use a db lock
|
||||
if (config('cache.default') == 'database' && ! \Schema::hasTable('cache_locks')) {
|
||||
$skip_schema_lock = true;
|
||||
}
|
||||
|
||||
$schemaLock = Cache::lock('schema', 86000);
|
||||
if (! empty($skip_schema_lock) || $schemaLock->get()) {
|
||||
$db_rev = get_db_schema();
|
||||
|
||||
$migrate_opts = ['--force' => true, '--ansi' => true];
|
||||
@@ -107,10 +99,5 @@ try {
|
||||
echo Artisan::output();
|
||||
}
|
||||
|
||||
if (isset($schemaLock)) {
|
||||
$schemaLock->release();
|
||||
}
|
||||
} catch (LockException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
$return = 1;
|
||||
$schemaLock->release();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user