Skip to content

Commit 05b4af4

Browse files
authored
feat: Add edxapp celery worker services (optional) (#69)
Copied worker configs from Confluence with the following changes: - Removed newrelic integration - Added mysql80 dependency for workes (not just mysql57) - Updated image to match the newer coordinates (matching lms and cms containers, which apparently both use `lms-dev`) - Added explanation to `C_FORCE_ROOT` - Fixed cms-worker hostname (was using `lms` in name) Supporting changes: - Add docs and comment explaining how to use the workers - Add cms-worker and lms-worker to the list of services available for CLI autocomplete Some mostly unrelated cleanup as well: - Update lms and cms Django settings argument from `devstack_docker` to just `devstack`; the former only imported the latter and that has been the case for years (after the switch from Vagrant). - Alphabetize service lists (cms was renamed from studio and should have been moved) - Fix some link syntax in the service list
1 parent 7098198 commit 05b4af4

5 files changed

+59
-9
lines changed

docker-compose-host.yml

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ services:
2929
- edxapp_tox:/edx/app/edxapp/edx-platform/.tox
3030
- edxapp_uploads:/edx/var/edxapp/uploads
3131
- ${DEVSTACK_WORKSPACE}/src:/edx/src
32+
lms-worker:
33+
volumes:
34+
- ${DEVSTACK_WORKSPACE}/edx-platform:/edx/app/edxapp/edx-platform
3235
edx_notes_api:
3336
volumes:
3437
- ${DEVSTACK_WORKSPACE}/edx-notes-api:/edx/app/notes/
@@ -47,6 +50,9 @@ services:
4750
- edxapp_tox:/edx/app/edxapp/edx-platform/.tox
4851
- edxapp_uploads:/edx/var/edxapp/uploads
4952
- ${DEVSTACK_WORKSPACE}/src:/edx/src
53+
cms-worker:
54+
volumes:
55+
- ${DEVSTACK_WORKSPACE}/edx-platform:/edx/app/edxapp/edx-platform
5056
insights:
5157
volumes:
5258
- ${DEVSTACK_WORKSPACE}/edx-analytics-dashboard:/edx/app/insights/insights

docker-compose.yml

+36-2
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ services:
406406
- "44567:4567"
407407

408408
lms:
409-
command: bash -c 'source /edx/app/edxapp/edxapp_env && while true; do python /edx/app/edxapp/edx-platform/manage.py lms runserver 0.0.0.0:18000 --settings devstack_docker; sleep 2; done'
409+
# Switch to `--settings devstack_with_worker` if you want to use lms-worker
410+
command: bash -c 'source /edx/app/edxapp/edxapp_env && while true; do python /edx/app/edxapp/edx-platform/manage.py lms runserver 0.0.0.0:18000 --settings devstack; sleep 2; done'
410411
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.lms"
411412
hostname: lms.devstack.edx
412413
depends_on:
@@ -446,6 +447,22 @@ services:
446447
volumes:
447448
- edxapp_lms_assets:/edx/var/edxapp/staticfiles/
448449

450+
lms-worker:
451+
command: bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && celery --app=lms.celery:APP worker -l debug -c 2'
452+
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.lms-worker"
453+
hostname: lms-worker.devstack.edx
454+
depends_on:
455+
- mysql80
456+
- mysql57
457+
- redis
458+
stdin_open: true
459+
tty: true
460+
image: edxops/lms-dev:latest
461+
environment:
462+
DJANGO_SETTINGS_MODULE: lms.envs.devstack_with_worker
463+
# Dangerous to run Celery as root normally, but it's how we do things in devstack for some reason
464+
C_FORCE_ROOT: "true"
465+
449466
insights:
450467
command: bash -c 'source /edx/app/insights/insights_env && while true; do python /edx/app/insights/insights/manage.py runserver 0.0.0.0:18110 --settings analytics_dashboard.settings.devstack; sleep 2; done'
451468
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.insights"
@@ -584,7 +601,8 @@ services:
584601
- /edx/var/registrar/
585602

586603
cms:
587-
command: bash -c 'source /edx/app/edxapp/edxapp_env && while true; do python /edx/app/edxapp/edx-platform/manage.py cms runserver 0.0.0.0:18010 --settings devstack_docker; sleep 2; done'
604+
# Switch to `--settings devstack_with_worker` if you want to use cms-worker
605+
command: bash -c 'source /edx/app/edxapp/edxapp_env && while true; do python /edx/app/edxapp/edx-platform/manage.py cms runserver 0.0.0.0:18010 --settings devstack; sleep 2; done'
588606
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.cms"
589607
hostname: cms.devstack.edx
590608
depends_on:
@@ -623,6 +641,22 @@ services:
623641
volumes:
624642
- edxapp_cms_assets:/edx/var/edxapp/staticfiles/
625643

644+
cms-worker:
645+
command: bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && celery --app=cms.celery:APP worker -l debug -c 2'
646+
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.lms-worker"
647+
hostname: cms-worker.devstack.edx
648+
depends_on:
649+
- mysql80
650+
- mysql57
651+
- redis
652+
stdin_open: true
653+
tty: true
654+
image: edxops/lms-dev:latest
655+
environment:
656+
DJANGO_SETTINGS_MODULE: cms.envs.devstack_with_worker
657+
# Dangerous to run Celery as root normally, but it's how we do things in devstack for some reason
658+
C_FORCE_ROOT: "true"
659+
626660
xqueue:
627661
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.xqueue"
628662
image: edxops/xqueue-dev:latest

docs/advanced_configuration.rst

+10
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ This is handled for you automatically by setting the ``OPENEDX_RELEASE`` environ
2525

2626
As a specific example, if ``OPENEDX_RELEASE`` is set in your environment as ``juniper.master``, then ``COMPOSE_PROJECT_NAME`` will default to ``devstack-juniper.master`` instead of ``devstack``.
2727

28+
Celery workers
29+
~~~~~~~~~~~~~~
30+
31+
In devstack, edxapp and possibly other services are configured to run Celery tasks synchronously rather than requiring another worker service to handle them. However, there is some support for using a separate worker. To use Celery for LMS or CMS:
32+
33+
1. Edit ``docker-compose.yml`` to update the LMS and CMS ``command`` lines to use ``--settings devstack_with_worker`` instead of just ``--settings devstack``
34+
2. Run ``make lms-worker-up cms-worker-up``
35+
3. Start LMS and CMS as usual
36+
37+
To verify that Celery communication is working, try ``curl -sS 'http://localhost:18000/heartbeat?extended'`` and confirm that the ``celery`` component of the response shows success.

docs/service_list.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ Instead of a service name or list, you can also run commands like ``make dev.pro
5555
+------------------------------------+-------------------------------------+----------------+--------------+
5656
| `xqueue`_ | http://localhost:18040/api/v1/ | Python/Django | Extra |
5757
+------------------------------------+-------------------------------------+----------------+--------------+
58-
| `coursegraph` | http://localhost:7474/browser | Tooling (Java) | Extra |
58+
| `coursegraph`_ | http://localhost:7474/browser | Tooling (Java) | Extra |
5959
+------------------------------------+-------------------------------------+----------------+--------------+
60-
| `insights` | http://localhost:18110 | Python/Django | Extra |
60+
| `insights`_ | http://localhost:18110 | Python/Django | Extra |
6161
+------------------------------------+-------------------------------------+----------------+--------------+
62-
| `analyticsapi` | http://localhost:19001 | Python/Django | Extra |
62+
| `analyticsapi`_ | http://localhost:19001 | Python/Django | Extra |
6363
+------------------------------------+-------------------------------------+----------------+--------------+
64-
| `frontend-app-ora-grading` | http://localhost:1993 | MFE (React.js) | Extra |
64+
| `frontend-app-ora-grading`_ | http://localhost:1993 | MFE (React.js) | Extra |
6565
+------------------------------------+-------------------------------------+----------------+--------------+
6666

6767
Some common service combinations include:

options.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ credentials+discovery+ecommerce+edx_notes_api+forum+frontend-app-authn+frontend-
6767
# Separated by plus signs.
6868
# Separated by plus signs. Listed in alphabetical order for clarity.
6969
EDX_SERVICES ?= \
70-
analyticsapi+credentials+discovery+ecommerce+edx_notes_api+forum+frontend-app-account+frontend-app-learner-dashboard+frontend-app-learner-record+frontend-app-profile+frontend-app-authn+frontend-app-course-authoring+frontend-app-gradebook+frontend-app-ora-grading+frontend-app-learning+frontend-app-library-authoring+frontend-app-payment+frontend-app-program-console+frontend-app-publisher+insights+lms+lms_watcher+registrar+registrar-worker+cms+cms_watcher+xqueue+xqueue_consumer
70+
analyticsapi+credentials+cms+cms-worker+cms_watcher+discovery+ecommerce+edx_notes_api+forum+frontend-app-account+frontend-app-learner-dashboard+frontend-app-learner-record+frontend-app-profile+frontend-app-authn+frontend-app-course-authoring+frontend-app-gradebook+frontend-app-ora-grading+frontend-app-learning+frontend-app-library-authoring+frontend-app-payment+frontend-app-program-console+frontend-app-publisher+insights+lms+lms-worker+lms_watcher+registrar+registrar-worker+xqueue+xqueue_consumer
7171

7272
# Services with database migrations.
7373
# Should be a subset of $(EDX_SERVICES).
@@ -76,7 +76,7 @@ analyticsapi+credentials+discovery+ecommerce+edx_notes_api+forum+frontend-app-ac
7676
# Note: This list should contain _all_ db-backed services, even if not
7777
# configured to run; the list will be filtered later against $(DEFAULT_SERVICES).
7878
DB_SERVICES ?= \
79-
credentials+discovery+ecommerce+lms+registrar+cms
79+
credentials+cms+discovery+ecommerce+lms+registrar
8080

8181
# Services with static assets to be built.
8282
# Should be a subset of $(EDX_SERVICES).
@@ -85,7 +85,7 @@ credentials+discovery+ecommerce+lms+registrar+cms
8585
# Note: This list should contain _all_ services with static asse to compile ts, even if not
8686
# configured to run; the list will be filtered later against $(DEFAULT_SERVICES).
8787
ASSET_SERVICES ?= \
88-
credentials+discovery+ecommerce+insights+lms+registrar+cms
88+
credentials+cms+discovery+ecommerce+insights+lms+registrar
8989

9090
# All third-party services.
9191
# Separated by plus signs. Listed in alphabetical order for clarity.

0 commit comments

Comments
 (0)