Skip to content

Commit

Permalink
feat: configure uwsgi through an ini file
Browse files Browse the repository at this point in the history
  • Loading branch information
MoisesGSalas authored and regisb committed Mar 15, 2023
1 parent 2399909 commit aac0355
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 10 deletions.
12 changes: 12 additions & 0 deletions changelog.d/20230310_021412_moises.gonzalez_configurable_uwsgi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!--
Create a changelog entry for every new user-facing change. Please respect the following instructions:
- Indicate breaking changes by prepending an explosion 💥 character.
- Prefix your changes with either [Bugfix], [Improvement], [Feature], [Security], [Deprecation].
- You may optionally append "(by @<author>)" at the end of the line, where "<author>" is either one (just one)
of your GitHub username, real name or affiliated organization. These affiliations will be displayed in
the release notes for every release.
-->

<!-- - 💥[Feature] Foobarize the blorginator. This breaks plugins by renaming the `FOO_DO` filter to `BAR_DO`. (by @regisb) -->
<!-- - [Improvement] This is a non-breaking change. Life is good. (by @billgates) -->
- [Improvement] Make it possible to extend or override the configuration of the uWSGI server. (by @MoisesGSalas)
11 changes: 11 additions & 0 deletions docs/reference/patches.rst
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,14 @@ Python-formatted LMS settings in development. Values defined here override the v
File: ``apps/openedx/settings/lms/production.py``

Python-formatted LMS settings in production. Values defined here override the values from :patch:`openedx-lms-common-settings`.

``uwsgi-config``
================

File: ``apps/openedx/settings/uwsgi.ini``

A .INI formatted file used to extend or override the uWSGI configuration.

Check the uWSGI documentation for more details about the `.INI format <https://uwsgi-docs.readthedocs.io/en/latest/Configuration.html#ini-files>`__ and the `list of available options <https://uwsgi-docs.readthedocs.io/en/latest/Options.html>`__.

.. patch:: uwsgi-config
3 changes: 3 additions & 0 deletions tutor/templates/apps/openedx/uwsgi.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% include "build/openedx/settings/uwsgi.ini" %}
{{ patch("uwsgi-config") }}

17 changes: 7 additions & 10 deletions tutor/templates/build/openedx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -251,17 +251,14 @@ CMD ./manage.py $SERVICE_VARIANT runserver 0.0.0.0:8000
###### Final image with production cmd
FROM production as final

# Default amount of uWSGI processes
ENV UWSGI_WORKERS=2

# Copy the default uWSGI configuration
COPY --chown=app:app settings/uwsgi.ini .

# Run server
CMD uwsgi \
--static-map /static=/openedx/staticfiles/ \
--static-map /media=/openedx/media/ \
--http 0.0.0.0:8000 \
--thunder-lock \
--single-interpreter \
--enable-threads \
--processes=${UWSGI_WORKERS:-2} \
--buffer-size=8192 \
--wsgi-file $SERVICE_VARIANT/wsgi.py
CMD uwsgi uwsgi.ini

{{ patch("openedx-dockerfile-final") }}

10 changes: 10 additions & 0 deletions tutor/templates/build/openedx/settings/uwsgi.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[uwsgi]
static-map = /static=/openedx/staticfiles/
static-map = /media=/openedx/media/
http = 0.0.0.0:8000
buffer-size = 8192
wsgi-file = $(SERVICE_VARIANT)/wsgi.py
processes = $(UWSGI_WORKERS)
thunder-lock = true
single-interpreter = true
enable-threads = true
18 changes: 18 additions & 0 deletions tutor/templates/k8s/deployments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ spec:
name: settings-cms
- mountPath: /openedx/config
name: config
- mountPath: /openedx/edx-platform/uwsgi.ini
name: uwsgi-config
subPath: uwsgi.ini
resources:
requests:
memory: 2Gi
Expand All @@ -111,6 +114,12 @@ spec:
- name: config
configMap:
name: openedx-config
- name: uwsgi-config
configMap:
name: openedx-uwsgi-config
items:
- key: uwsgi.ini
path: uwsgi.ini
---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -198,6 +207,9 @@ spec:
name: settings-cms
- mountPath: /openedx/config
name: config
- mountPath: /openedx/edx-platform/uwsgi.ini
name: uwsgi-config
subPath: uwsgi.ini
resources:
requests:
memory: 2Gi
Expand All @@ -213,6 +225,12 @@ spec:
- name: config
configMap:
name: openedx-config
- name: uwsgi-config
configMap:
name: openedx-uwsgi-config
items:
- key: uwsgi.ini
path: uwsgi.ini
---
apiVersion: apps/v1
kind: Deployment
Expand Down
6 changes: 6 additions & 0 deletions tutor/templates/kustomization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ configMapGenerator:
options:
labels:
app.kubernetes.io/name: openedx
- name: openedx-uwsgi-config
files:
- apps/openedx/uwsgi.ini
options:
labels:
app.kubernetes.io/name: openedx
- name: redis-config
files:
- apps/redis/redis.conf
Expand Down
2 changes: 2 additions & 0 deletions tutor/templates/local/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ services:
- ../apps/openedx/settings/lms:/openedx/edx-platform/lms/envs/tutor:ro
- ../apps/openedx/settings/cms:/openedx/edx-platform/cms/envs/tutor:ro
- ../apps/openedx/config:/openedx/config:ro
- ../apps/openedx/uwsgi.ini:/openedx/edx-platform/uwsgi.ini:ro
- ../../data/lms:/openedx/data
- ../../data/openedx-media:/openedx/media
depends_on:
Expand Down Expand Up @@ -142,6 +143,7 @@ services:
- ../apps/openedx/settings/lms:/openedx/edx-platform/lms/envs/tutor:ro
- ../apps/openedx/settings/cms:/openedx/edx-platform/cms/envs/tutor:ro
- ../apps/openedx/config:/openedx/config:ro
- ../apps/openedx/uwsgi.ini:/openedx/edx-platform/uwsgi.ini:ro
- ../../data/cms:/openedx/data
- ../../data/openedx-media:/openedx/media
depends_on:
Expand Down

0 comments on commit aac0355

Please sign in to comment.