diff --git a/docker/README.md b/docker/README.md --- a/docker/README.md +++ b/docker/README.md @@ -660,3 +660,14 @@ --end-object 000001 \ --dry-run ``` + +## Using Sentry + +All entrypoints to SWH code (CLI, gunicorn, celery, ...) are, or should be, +intrumented using Sentry. By default this is disabled, but if you run your +own Sentry instance, you can use it. + +To do so, you must get a DSN from your Sentry instance, and set it as the +value of `SWH_SENTRY_DSN` in the file `env/common_python.env`. +You may also set it per-service in the `environment` section of each services +in `docker-compose.override.yml`. diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -87,6 +87,7 @@ swh-scheduler-db: image: postgres:11 env_file: + - ./env/common_python.env - ./env/scheduler-db.env environment: # unset PGHOST as db service crashes otherwise @@ -96,6 +97,7 @@ image: swh/stack build: ./ env_file: + - ./env/common_python.env - ./env/scheduler-db.env - ./env/scheduler.env - ./env/statsd.env @@ -115,6 +117,7 @@ image: swh/stack build: ./ env_file: + - ./env/common_python.env - ./env/scheduler-db.env - ./env/scheduler.env - ./env/statsd.env @@ -134,6 +137,7 @@ image: swh/stack build: ./ env_file: + - ./env/common_python.env - ./env/scheduler-db.env - ./env/scheduler.env - ./env/statsd.env @@ -169,6 +173,7 @@ - swh-objstorage - kafka env_file: + - ./env/common_python.env - ./env/storage-db.env - ./env/statsd.env environment: @@ -187,6 +192,7 @@ ports: - 5003:5003 env_file: + - ./env/common_python.env - ./env/statsd.env environment: SWH_CONFIG_FILENAME: /objstorage.yml @@ -213,6 +219,7 @@ depends_on: - swh-idx-storage-db env_file: + - ./env/common_python.env - ./env/indexers-db.env environment: SWH_CONFIG_FILENAME: /indexer_storage.yml @@ -233,6 +240,7 @@ - swh-storage - swh-idx-storage env_file: + - ./env/common_python.env - ./env/statsd.env environment: VERBOSITY: 3 @@ -260,13 +268,13 @@ - swh-deposit-db - swh-scheduler env_file: + - ./env/common_python.env - ./env/statsd.env + - ./env/deposit-db.env environment: VERBOSITY: 3 SWH_CONFIG_FILENAME: /deposit.yml DJANGO_SETTINGS_MODULE: swh.deposit.settings.production - env_file: - - ./env/deposit-db.env entrypoint: /entrypoint.sh volumes: - "./conf/deposit.yml:/deposit.yml:ro" @@ -284,6 +292,7 @@ image: swh/stack build: ./ env_file: + - ./env/common_python.env - ./env/vault-db.env - ./env/statsd.env environment: @@ -306,6 +315,7 @@ build: ./ command: worker env_file: + - ./env/common_python.env - ./env/statsd.env environment: SWH_CONFIG_FILENAME: /cooker.yml @@ -332,6 +342,7 @@ image: swh/stack build: ./ env_file: + - ./env/common_python.env - ./env/listers-db.env - ./env/listers.env - ./env/statsd.env @@ -356,6 +367,7 @@ image: swh/stack build: ./ env_file: + - ./env/common_python.env - ./env/listers.env - ./env/statsd.env user: swh @@ -378,6 +390,7 @@ build: ./ user: swh env_file: + - ./env/common_python.env - ./env/indexers-db.env - ./env/indexers.env - ./env/statsd.env @@ -398,6 +411,8 @@ image: swh/stack build: ./ entrypoint: /entrypoint.sh + env_file: + - ./env/common_python.env depends_on: - kafka - swh-storage diff --git a/docker/env/common_python.env b/docker/env/common_python.env new file mode 100644 --- /dev/null +++ b/docker/env/common_python.env @@ -0,0 +1,5 @@ +# Forces Python's stdout to be shown in docker logs before they exit: +PYTHONUNBUFFERED=1 + +# Uncomment and set this to a Sentry DSN to report errors to Sentry: +# SWH_SENTRY_DSN= diff --git a/docker/services/swh-deposit/entrypoint.sh b/docker/services/swh-deposit/entrypoint.sh --- a/docker/services/swh-deposit/entrypoint.sh +++ b/docker/services/swh-deposit/entrypoint.sh @@ -31,5 +31,6 @@ --workers 2 \ --log-level DEBUG \ --timeout 3600 \ + --config 'python:swh.core.api.gunicorn_config' \ 'django.core.wsgi:get_wsgi_application()' fi diff --git a/docker/services/swh-indexer-storage/entrypoint.sh b/docker/services/swh-indexer-storage/entrypoint.sh --- a/docker/services/swh-indexer-storage/entrypoint.sh +++ b/docker/services/swh-indexer-storage/entrypoint.sh @@ -27,6 +27,7 @@ --workers 2 \ --log-level DEBUG \ --timeout 3600 \ + --config 'python:swh.core.api.gunicorn_config' \ 'swh.indexer.storage.api.server:make_app_from_configfile()' ;; esac diff --git a/docker/services/swh-objstorage/entrypoint.sh b/docker/services/swh-objstorage/entrypoint.sh --- a/docker/services/swh-objstorage/entrypoint.sh +++ b/docker/services/swh-objstorage/entrypoint.sh @@ -19,6 +19,7 @@ --workers 2 \ --reload \ --timeout 3600 \ + --config 'python:swh.core.api.gunicorn_config' \ 'swh.objstorage.api.server:make_app_from_configfile()' fi diff --git a/docker/services/swh-scheduler/entrypoint.sh b/docker/services/swh-scheduler/entrypoint.sh --- a/docker/services/swh-scheduler/entrypoint.sh +++ b/docker/services/swh-scheduler/entrypoint.sh @@ -29,6 +29,7 @@ --workers 2 \ --reload \ --timeout 3600 \ + --config 'python:swh.core.api.gunicorn_config' \ 'swh.scheduler.api.server:make_app_from_configfile()' esac diff --git a/docker/services/swh-search/entrypoint.sh b/docker/services/swh-search/entrypoint.sh --- a/docker/services/swh-search/entrypoint.sh +++ b/docker/services/swh-search/entrypoint.sh @@ -26,6 +26,7 @@ --workers 2 \ --log-level DEBUG \ --timeout 3600 \ + --config 'python:swh.core.api.gunicorn_config' \ 'swh.search.api.server:make_app_from_configfile()' ;; esac diff --git a/docker/services/swh-storage-replayer/entrypoint.sh b/docker/services/swh-storage-replayer/entrypoint.sh --- a/docker/services/swh-storage-replayer/entrypoint.sh +++ b/docker/services/swh-storage-replayer/entrypoint.sh @@ -20,7 +20,7 @@ --db-name ${POSTGRES_DB} storage echo Starting the swh-storage Kafka storage replayer - exec swh-journal replay \ + exec swh journal replay \ --broker kafka \ --prefix swh.journal.objects \ --consumer-id swh.storage.replica diff --git a/docker/services/swh-storage/entrypoint.sh b/docker/services/swh-storage/entrypoint.sh --- a/docker/services/swh-storage/entrypoint.sh +++ b/docker/services/swh-storage/entrypoint.sh @@ -40,6 +40,7 @@ --workers 2 \ --log-level DEBUG \ --timeout 3600 \ + --config 'python:swh.core.api.gunicorn_config' \ 'swh.storage.api.server:make_app_from_configfile()' ;; esac diff --git a/docker/services/swh-web/entrypoint.sh b/docker/services/swh-web/entrypoint.sh --- a/docker/services/swh-web/entrypoint.sh +++ b/docker/services/swh-web/entrypoint.sh @@ -34,5 +34,6 @@ --threads 2 \ --workers 2 \ --timeout 3600 \ + --config 'python:swh.web.gunicorn_config' \ 'django.core.wsgi:get_wsgi_application()' esac