diff --git a/chart/templates/backend.yaml b/chart/templates/backend.yaml index 7097636b30..e61252965f 100644 --- a/chart/templates/backend.yaml +++ b/chart/templates/backend.yaml @@ -147,6 +147,12 @@ spec: - name: op image: {{ .Values.backend_image }} imagePullPolicy: {{ .Values.backend_pull_policy }} + {{- if .Values.backend_op_command_override }} + command: + {{- range .Values.backend_op_command_override }} + - {{ . | quote }} + {{- end }} + {{- else }} command: - gunicorn - btrixcloud.main_op:app_root @@ -158,7 +164,7 @@ spec: - "{{ .Values.backend_workers | default 1 }}" - --worker-class - uvicorn.workers.UvicornWorker - + {{- end }} envFrom: - configMapRef: name: backend-env-config diff --git a/docs/develop/backend-hot-reload-and-debugger.md b/docs/develop/backend-hot-reload-and-debugger.md index dffc8c1c6f..03c87a2b7e 100644 --- a/docs/develop/backend-hot-reload-and-debugger.md +++ b/docs/develop/backend-hot-reload-and-debugger.md @@ -26,19 +26,25 @@ skaffold dev ``` This will deploy Browsertrix into the cluster and port forward the API with hot reloading. -Navigate to `localhost:8000/api/redoc` or `localhost:8000/api/docs` to see the documentation. -Changing any code in `backend/btrixcloud` will trigger a reload. + +Navigate to `localhost:8000/api/redoc` or `localhost:8000/api/docs` to see the documentation +for the api container. + +Navigate to `http://localhost:8756/redoc` or `http://localhost:8756/docs` to see the documentation +for the op container. + +Changing any code in `backend/btrixcloud` will trigger a reload in both the op and api containers. ### Debugger Interactive debugging uses [debugpy](https://github.com/microsoft/debugpy), which works on VSCode but not PyCharm. -Use this debug configuration in VSCode: +Use these debug configurations in VSCode: ```JSON { - "name": "Attach to Browsertrix Backend", + "name": "Attach to Browsertrix Backend API", "type": "debugpy", "request": "attach", "connect": { @@ -52,6 +58,22 @@ Use this debug configuration in VSCode: } ], "justMyCode": false +}, +{ + "name": "Attach to Browsertrix Backend OP", + "type": "debugpy", + "request": "attach", + "connect": { + "host": "127.0.0.1", + "port": 5679 + }, + "pathMappings": [ + { + "localRoot": "${workspaceFolder}/backend/btrixcloud/", + "remoteRoot": "/app/btrixcloud/" + } + ], + "justMyCode": false } ``` diff --git a/skaffold.yaml b/skaffold.yaml index 96e870b50a..a156fd7544 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -27,6 +27,19 @@ portForward: namespace: default port: 5678 localPort: 5678 +# so you can hit the op container on `localhost:8756` +- resourceType: service + resourceName: browsertrix-cloud-backend + namespace: default + # can't references {{ Values. }} hence hardcoding + port: 8756 + localPort: 8756 +# for the debugger +- resourceType: deployment + resourceName: browsertrix-cloud-backend + namespace: default + port: 5679 + localPort: 5679 deploy: helm: releases: @@ -39,6 +52,9 @@ deploy: # See https://skaffold.dev/docs/deployers/helm/ # must do this to make skaffold use local images with helm setValues: + # we hardcoded this earlier so make sure it has same value + # across the helm chart + opPort: 8756 # hot reloading doesn't work with default gunicorn command # so need to override to use uvicorn # plus need to start the process with debugpy to debug @@ -51,3 +67,12 @@ deploy: python -m debugpy --listen 0.0.0.0:5678 -m uvicorn btrixcloud.main:app_root --reload --host 0.0.0.0 --port 8000 + backend_op_command_override: + - sh + - -c + - > + pip install --no-input debugpy + && + python -m debugpy --listen 0.0.0.0:5679 + -m uvicorn btrixcloud.main_op:app_root + --reload --host 0.0.0.0 --port 8756 \ No newline at end of file