From d7824e24c71117cf1df11a25a8c6cd637ec14c8f Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Sun, 26 Jun 2022 19:21:46 -0400 Subject: [PATCH] APPRISE_API_WORKER_COUNT environment variable added --- README.md | 1 + apprise_api/gunicorn.conf.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 699512f..091714e 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,7 @@ The use of environment variables allow you to provide over-rides to default sett | `SECRET_KEY` | A Django variable acting as a *salt* for most things that require security. This API uses it for the hash sequences when writing the configuration files to disk (`hash` mode only). | `ALLOWED_HOSTS` | A list of strings representing the host/domain names that this API can serve. This is a security measure to prevent HTTP Host header attacks, which are possible even under many seemingly-safe web server configurations. By default this is set to `*` allowing any host. Use space to delimit more than one host. | `APPRISE_RECURSION_MAX` | This defines the number of times one Apprise API Server can (recursively) call another. This is to both support and mitigate abuse through [the `apprise://` schema](https://github.com/caronc/apprise/wiki/Notify_apprise_api) for those who choose to use it. When leveraged properly, you can increase this (recursion max) value and successfully load balance the handling of many notification requests through many additional API Servers. By default this value is set to `1` (one). +| `APPRISE_WORKER_COUNT` | Defines the number of workers to run. by default this is calculated based on the number of threads detected. | `BASE_URL` | Those who are hosting the API behind a proxy that requires a subpath to gain access to this API should specify this path here as well. By default this is not set at all. | `LOG_LEVEL` | Adjust the log level to the console. Possible values are `CRITICAL`, `ERROR`, `WARNING`, `INFO`, and `DEBUG`. | `DEBUG` | This defaults to `no` and can however be set to `yes` by simply defining the global variable as such. diff --git a/apprise_api/gunicorn.conf.py b/apprise_api/gunicorn.conf.py index bac8829..66eb8ca 100644 --- a/apprise_api/gunicorn.conf.py +++ b/apprise_api/gunicorn.conf.py @@ -22,6 +22,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +import os import multiprocessing # This file is launched with the call: @@ -41,7 +42,8 @@ bind = [ ] # Workers are relative to the number of CPU's provided by hosting server -workers = multiprocessing.cpu_count() * 2 + 1 +workers = int(os.environ.get( + 'APPRISE_WORKER_COUNT', multiprocessing.cpu_count() * 2 + 1)) # Increase worker timeout value to give upstream services time to # respond