From 35800e21c713e53060d29cef4c617284927c5776 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 19 Mar 2024 10:17:36 +0100 Subject: [PATCH] Allow customization of cache and log directory (#3997) On systems that follow the FHS it may be desirable to separate logs and cache files into dedicated base directories (e.g. /var/log/pretix or /var/cache/pretix). --- doc/admin/config.rst | 8 ++++++++ src/pretix/settings.py | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/admin/config.rst b/doc/admin/config.rst index 4cb99372f..bc6169f1b 100644 --- a/doc/admin/config.rst +++ b/doc/admin/config.rst @@ -52,10 +52,18 @@ Example:: ``currency`` The default currency as a three-letter code. Defaults to ``EUR``. +``cachedir`` + The local path to a directory where temporary files will be stored. + Defaults to the ``cache`` directory below the ``datadir``. + ``datadir`` The local path to a data directory that will be used for storing user uploads and similar data. Defaults to the value of the environment variable ``DATA_DIR`` or ``data``. +``logdir`` + The local path to a directory where log files will be stored. + Defaults to the ``logs`` directory below the ``datadir``. + ``plugins_default`` A comma-separated list of plugins that are enabled by default for all new events. Defaults to ``pretix.plugins.sendmail,pretix.plugins.statistics``. diff --git a/src/pretix/settings.py b/src/pretix/settings.py index 5721c3c4d..0b34ca45e 100644 --- a/src/pretix/settings.py +++ b/src/pretix/settings.py @@ -65,10 +65,10 @@ config = EnvOrParserConfig(_config) CONFIG_FILE = config DATA_DIR = config.get('pretix', 'datadir', fallback=os.environ.get('DATA_DIR', 'data')) -LOG_DIR = os.path.join(DATA_DIR, 'logs') +LOG_DIR = config.get('pretix', 'logdir', fallback=os.path.join(DATA_DIR, 'logs')) MEDIA_ROOT = os.path.join(DATA_DIR, 'media') PROFILE_DIR = os.path.join(DATA_DIR, 'profiles') -CACHE_DIR = os.path.join(DATA_DIR, 'cache') +CACHE_DIR = config.get('pretix', 'cachedir', fallback=os.path.join(DATA_DIR, 'cache')) if not os.path.exists(DATA_DIR): os.mkdir(DATA_DIR)