From 38ea8b390e0fe804e44363ad16b09f1eefffcdca Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Sun, 18 Feb 2024 08:02:29 -0500 Subject: [PATCH] ensure int config values are above 0 --- relay/config.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/relay/config.py b/relay/config.py index eff6215..a451347 100644 --- a/relay/config.py +++ b/relay/config.py @@ -190,4 +190,14 @@ class Config: if key in {'port', 'pg_port', 'workers'} and not isinstance(value, int): value = int(value) + if value < 1: + if key == 'port': + value = 8080 + + elif key == 'pg_port': + value = 5432 + + elif key == 'workers': + value = len(os.sched_getaffinity(0)) + setattr(self, key, value)