From 4269074944a9e33144dfea350818239c61cab906 Mon Sep 17 00:00:00 2001 From: hashworks Date: Wed, 21 Dec 2022 22:28:16 +0100 Subject: [PATCH] Add ability to provide the configuration file path using an env variable --- docs/configuration.md | 12 +++++------- src/paperless/settings.py | 5 ++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 488a6f11f..d6041f0a5 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -10,12 +10,10 @@ run paperless, these settings have to be defined in different places. - If you are running paperless on anything else, paperless will search for the configuration file in these locations and use the first one it finds: - - ``` - /path/to/paperless/paperless.conf - /etc/paperless.conf - /usr/local/etc/paperless.conf - ``` + - The environment variable `PAPERLESS_CONFIGURATION_PATH` + - `/path/to/paperless/paperless.conf` + - `/etc/paperless.conf` + - `/usr/local/etc/paperless.conf` ## Required services @@ -678,7 +676,7 @@ paperless will process in parallel on a single document. count, with a slight favor towards threads per worker: | CPU core count | Workers | Threads | - |----------------|---------|---------| + | -------------- | ------- | ------- | | > 1 | > 1 | > 1 | | > 2 | > 2 | > 1 | | > 4 | > 2 | > 2 | diff --git a/src/paperless/settings.py b/src/paperless/settings.py index db26ba3b3..e16662c5a 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -17,7 +17,10 @@ from django.utils.translation import gettext_lazy as _ from dotenv import load_dotenv # Tap paperless.conf if it's available -if os.path.exists("../paperless.conf"): +configuration_path = os.getenv("PAPERLESS_CONFIGURATION_PATH") +if configuration_path and os.path.exists(configuration_path): + load_dotenv(configuration_path) +elif os.path.exists("../paperless.conf"): load_dotenv("../paperless.conf") elif os.path.exists("/etc/paperless.conf"): load_dotenv("/etc/paperless.conf")