mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
nextcloud: Use a separate DB for redis
- While nextcloud has a good prefix for all the keys it stores, flushing the database (for nextcloud or other apps) is easier if it stores it's keys in a separate database. Assign DB index at 8 (database number 9). Index 7 is taken by rspamd on FreedomBox. - Flush only Nextcloud's DB after restore instead of the entire server. - Ignore errors during flush if redis server is not running. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
12374d8783
commit
547db1608b
@ -25,6 +25,7 @@ DB_HOST = 'localhost'
|
|||||||
DB_NAME = 'nextcloud_fbx'
|
DB_NAME = 'nextcloud_fbx'
|
||||||
DB_USER = 'nextcloud_fbx'
|
DB_USER = 'nextcloud_fbx'
|
||||||
GUI_ADMIN = 'nextcloud-admin'
|
GUI_ADMIN = 'nextcloud-admin'
|
||||||
|
REDIS_DB = 8 # Don't clash with other redis apps
|
||||||
|
|
||||||
_volume_path = pathlib.Path(
|
_volume_path = pathlib.Path(
|
||||||
'/var/lib/containers/storage/volumes/') / VOLUME_NAME
|
'/var/lib/containers/storage/volumes/') / VOLUME_NAME
|
||||||
@ -338,7 +339,8 @@ def restore_database():
|
|||||||
|
|
||||||
_set_database_privileges(_get_dbpassword())
|
_set_database_privileges(_get_dbpassword())
|
||||||
|
|
||||||
action_utils.service_restart('redis-server')
|
subprocess.run(['redis-cli', '-n', REDIS_DB, 'FLUSHDB', 'SYNC'],
|
||||||
|
check=False)
|
||||||
_set_maintenance_mode(False)
|
_set_maintenance_mode(False)
|
||||||
|
|
||||||
# Attempts to update UUIDs of user and group entries. By default,
|
# Attempts to update UUIDs of user and group entries. By default,
|
||||||
@ -364,11 +366,11 @@ def _get_dbpassword():
|
|||||||
def _create_redis_config():
|
def _create_redis_config():
|
||||||
"""Create a php file for Redis configuration."""
|
"""Create a php file for Redis configuration."""
|
||||||
config_file = _volume_path / '_data/config/freedombox.config.php'
|
config_file = _volume_path / '_data/config/freedombox.config.php'
|
||||||
file_content = r'''<?php
|
file_content = fr'''<?php
|
||||||
$CONFIG = [
|
$CONFIG = [
|
||||||
'memcache.distributed' => '\OC\Memcache\Redis',
|
'memcache.distributed' => '\OC\Memcache\Redis',
|
||||||
'memcache.locking' => '\OC\Memcache\Redis',
|
'memcache.locking' => '\OC\Memcache\Redis',
|
||||||
'redis' => ['host' => '/run/redis/redis-server.sock'],
|
'redis' => ['host' => '/run/redis/redis-server.sock', 'dbindex' => {REDIS_DB}],
|
||||||
];
|
];
|
||||||
'''
|
'''
|
||||||
config_file.write_text(file_content)
|
config_file.write_text(file_content)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user