slightly safer config variable setting#62
Open
megies wants to merge 1 commit into
Open
Conversation
could make an actual difference if the desired value is set as an OS environment variable and if that value evaluates to False with bool() E.g. if trying to set an empty string or the number zero it might inadvertantly get overridden by the default value from config
NikolaosSokos
added a commit
to NikolaosSokos/ws-availability
that referenced
this pull request
May 28, 2026
Static check: regex over config.py.sample fails if anyone reintroduces the `os.environ.get(...) or DEFAULT` shape that PR EIDA#62 replaced. The `or` form falls back to DEFAULT when env is the empty string (and, in numeric contexts, when env is "0"), silently ignoring an operator who genuinely wants to set that value.
NikolaosSokos
added a commit
to NikolaosSokos/ws-availability
that referenced
this pull request
May 28, 2026
BETA.md updates from Tobias's beta review: - Step 2 install: `cp -n config.py.sample config.py` (no-clobber) replaces the two-line `[ -f config.py ] || cp ...` conditional. - Sentry example for v1.0.3 upgraders uses the PR EIDA#62 safer pattern `os.environ.get("X", default)` (we don't want operators copying the old leaky shape we just removed). - One-sentence callout at the top of Install explaining config.py is now the only place for MongoDB / FDSNWS-Station / Sentry settings — paired with the runtime change from commit 30c86b5. Regression tests in tests/test_docker_compose.py: - BETA.md must contain `cp -n config.py.sample config.py` and must NOT contain the conditional pattern. - BETA.md code snippets must NOT use `os.environ.get(...) or X`. 61/61 tests pass.
NikolaosSokos
added a commit
to NikolaosSokos/ws-availability
that referenced
this pull request
May 28, 2026
Tobias's beta review: "I do firmly believe the number of workers should be settable in the config, as opposed to having to patch the actual code — even if it's in a yaml." Adds gunicorn.conf.py which reads workers from Config.GUNICORN_WORKERS, defaulting to 1 when config.py isn't present (gunicorn must always be able to boot). docker-compose.yml's api command now invokes gunicorn with -c gunicorn.conf.py instead of a hardcoded --workers; same change on Dockerfile.api's CMD so the image works without compose too. config.py.sample gets GUNICORN_WORKERS = 1 in both RUNMODE blocks plus an int-coerced env override using the PR EIDA#62 safer pattern. README.md gains a config-table row and the Tuning section now points at config.py. Tests (tests/test_gunicorn_conf.py): - workers reads from Config.GUNICORN_WORKERS when present - falls back to 1 when GUNICORN_WORKERS missing - falls back to 1 when config.py itself is missing - coerces string env value to int - docker-compose api command uses -c gunicorn.conf.py, no hardcoded --workers - Dockerfile.api COPYs gunicorn.conf.py into the image 67/67 tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Could make an actual difference if the desired value is set as an OS environment variable and if that value evaluates to
Falsewithbool()E.g. if trying to set an empty string or the number zero it might inadvertently get overridden by the default value from config.
Wasn't sure what branch to base it on, can rebase it or just cherry-pick this wherever appropriate.