aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-05-27 20:56:03 +0100
committerMatthew Lemon <y@yulqen.org>2024-05-27 20:56:03 +0100
commit271bc7c662ab59f562be01470e9b4fafed107a90 (patch)
tree7b825a1011666af43e2b71b1f5c528d9750f3a37
parent0ec7b9c700c820ddd3b90f060af42000a60178cc (diff)
Removes most celery, storages and sentry config
Comments out in the settings files. Leaves a couple of imports of celery, but we're not removing the requirements on celery so should be fine, it will be installed. Comments out storages and sentry code. Leaves it all in Dockerfile and compose, but this change is aimed at getting Django running WITHOUT docker and compose.
-rw-r--r--config/settings/base.py125
-rw-r--r--config/settings/production.py130
2 files changed, 125 insertions, 130 deletions
diff --git a/config/settings/base.py b/config/settings/base.py
index def232c..9414953 100644
--- a/config/settings/base.py
+++ b/config/settings/base.py
@@ -260,38 +260,39 @@ LOGGING = {
# Celery
# ------------------------------------------------------------------------------
-if USE_TZ:
- # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-timezone
- CELERY_TIMEZONE = TIME_ZONE
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-broker_url
-CELERY_BROKER_URL = env("CELERY_BROKER_URL")
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-result_backend
-CELERY_RESULT_BACKEND = CELERY_BROKER_URL
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-extended
-CELERY_RESULT_EXTENDED = True
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-backend-always-retry
-# https://github.com/celery/celery/pull/6122
-CELERY_RESULT_BACKEND_ALWAYS_RETRY = True
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-backend-max-retries
-CELERY_RESULT_BACKEND_MAX_RETRIES = 10
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-accept_content
-CELERY_ACCEPT_CONTENT = ["json"]
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-task_serializer
-CELERY_TASK_SERIALIZER = "json"
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-result_serializer
-CELERY_RESULT_SERIALIZER = "json"
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#task-time-limit
-# TODO: set to whatever value is adequate in your circumstances
-CELERY_TASK_TIME_LIMIT = 5 * 60
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#task-soft-time-limit
-# TODO: set to whatever value is adequate in your circumstances
-CELERY_TASK_SOFT_TIME_LIMIT = 60
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#beat-scheduler
-CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#worker-send-task-events
-CELERY_WORKER_SEND_TASK_EVENTS = True
-# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-task_send_sent_event
-CELERY_TASK_SEND_SENT_EVENT = True
+# if USE_TZ:
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-timezone
+# CELERY_TIMEZONE = TIME_ZONE
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-broker_url
+# CELERY_BROKER_URL = env("CELERY_BROKER_URL")
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-result_backend
+# CELERY_RESULT_BACKEND = CELERY_BROKER_URL
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-extended
+# CELERY_RESULT_EXTENDED = True
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-backend-always-retry
+# # https://github.com/celery/celery/pull/6122
+# CELERY_RESULT_BACKEND_ALWAYS_RETRY = True
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-backend-max-retries
+# CELERY_RESULT_BACKEND_MAX_RETRIES = 10
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-accept_content
+# CELERY_ACCEPT_CONTENT = ["json"]
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-task_serializer
+# CELERY_TASK_SERIALIZER = "json"
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-result_serializer
+# CELERY_RESULT_SERIALIZER = "json"
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#task-time-limit
+# # TODO: set to whatever value is adequate in your circumstances
+# CELERY_TASK_TIME_LIMIT = 5 * 60
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#task-soft-time-limit
+# # TODO: set to whatever value is adequate in your circumstances
+# CELERY_TASK_SOFT_TIME_LIMIT = 60
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#beat-scheduler
+# CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#worker-send-task-events
+# CELERY_WORKER_SEND_TASK_EVENTS = True
+# # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-task_send_sent_event
+# CELERY_TASK_SEND_SENT_EVENT = True
+
# django-allauth
# ------------------------------------------------------------------------------
ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_ACCOUNT_ALLOW_REGISTRATION", True)
@@ -316,36 +317,36 @@ SOCIALACCOUNT_FORMS = {"signup": "pyblackbird_cc.users.forms.UserSocialSignupFor
# STORAGES
# ------------------------------------------------------------------------------
-# https://django-storages.readthedocs.io/en/latest/#installation
-INSTALLED_APPS += ["storages"]
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-# AWS_ACCESS_KEY_ID = env("DJANGO_AWS_ACCESS_KEY_ID")
-AWS_ACCESS_KEY_ID = env("SPACES_KEY")
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-# AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY")
-AWS_SECRET_ACCESS_KEY = env("SPACES_SECRET")
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-# AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_BUCKET_NAME")
-AWS_STORAGE_BUCKET_NAME = env("SPACES_BUCKET_NAME")
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-AWS_QUERYSTRING_AUTH = False
-# DO NOT change these unless you know what you're doing.
-_AWS_EXPIRY = 60 * 60 * 24 * 7
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-AWS_S3_OBJECT_PARAMETERS = {
- "CacheControl": f"max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate",
-}
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-AWS_S3_MAX_MEMORY_SIZE = env.int(
- "DJANGO_AWS_S3_MAX_MEMORY_SIZE",
- default=100_000_000, # 100MB
-)
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-AWS_S3_REGION_NAME = env("DJANGO_AWS_S3_REGION_NAME", default=None)
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#cloudfront
-AWS_S3_CUSTOM_DOMAIN = env("DJANGO_AWS_S3_CUSTOM_DOMAIN", default=None)
-aws_s3_domain = AWS_S3_CUSTOM_DOMAIN or f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com"
-AWS_S3_ENDPOINT_URL = env("SPACES_ENDPOINT_URL")
+# # https://django-storages.readthedocs.io/en/latest/#installation
+# INSTALLED_APPS += ["storages"]
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# # AWS_ACCESS_KEY_ID = env("DJANGO_AWS_ACCESS_KEY_ID")
+# AWS_ACCESS_KEY_ID = env("SPACES_KEY")
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# # AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY")
+# AWS_SECRET_ACCESS_KEY = env("SPACES_SECRET")
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# # AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_BUCKET_NAME")
+# AWS_STORAGE_BUCKET_NAME = env("SPACES_BUCKET_NAME")
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_QUERYSTRING_AUTH = False
+# # DO NOT change these unless you know what you're doing.
+# _AWS_EXPIRY = 60 * 60 * 24 * 7
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_S3_OBJECT_PARAMETERS = {
+# "CacheControl": f"max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate",
+# }
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_S3_MAX_MEMORY_SIZE = env.int(
+# "DJANGO_AWS_S3_MAX_MEMORY_SIZE",
+# default=100_000_000, # 100MB
+# )
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_S3_REGION_NAME = env("DJANGO_AWS_S3_REGION_NAME", default=None)
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#cloudfront
+# AWS_S3_CUSTOM_DOMAIN = env("DJANGO_AWS_S3_CUSTOM_DOMAIN", default=None)
+# aws_s3_domain = AWS_S3_CUSTOM_DOMAIN or f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com"
+# AWS_S3_ENDPOINT_URL = env("SPACES_ENDPOINT_URL")
# Your stuff...
# ------------------------------------------------------------------------------
diff --git a/config/settings/production.py b/config/settings/production.py
index a44c994..63afa6d 100644
--- a/config/settings/production.py
+++ b/config/settings/production.py
@@ -1,11 +1,5 @@
# ruff: noqa: E501
-import logging
-import sentry_sdk
-from sentry_sdk.integrations.celery import CeleryIntegration
-from sentry_sdk.integrations.django import DjangoIntegration
-from sentry_sdk.integrations.logging import LoggingIntegration
-from sentry_sdk.integrations.redis import RedisIntegration
from .base import * # noqa: F403
from .base import DATABASES
@@ -65,47 +59,47 @@ SECURE_CONTENT_TYPE_NOSNIFF = env.bool(
default=True,
)
-# STORAGES
-# ------------------------------------------------------------------------------
-# https://django-storages.readthedocs.io/en/latest/#installation
-INSTALLED_APPS += ["storages"]
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-AWS_ACCESS_KEY_ID = env("DJANGO_AWS_ACCESS_KEY_ID")
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY")
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_BUCKET_NAME")
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-AWS_QUERYSTRING_AUTH = False
-# DO NOT change these unless you know what you're doing.
-_AWS_EXPIRY = 60 * 60 * 24 * 7
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-AWS_S3_OBJECT_PARAMETERS = {
- "CacheControl": f"max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate",
-}
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-AWS_S3_MAX_MEMORY_SIZE = env.int(
- "DJANGO_AWS_S3_MAX_MEMORY_SIZE",
- default=100_000_000, # 100MB
-)
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
-AWS_S3_REGION_NAME = env("DJANGO_AWS_S3_REGION_NAME", default=None)
-# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#cloudfront
-AWS_S3_CUSTOM_DOMAIN = env("DJANGO_AWS_S3_CUSTOM_DOMAIN", default=None)
-aws_s3_domain = AWS_S3_CUSTOM_DOMAIN or f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com"
-# STATIC & MEDIA
-# ------------------------
-STORAGES = {
- "default": {
- "BACKEND": "django.core.files.storage.FileSystemStorage",
- },
- "staticfiles": {
- "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
- },
-}
-MEDIA_URL = f"https://{aws_s3_domain}/media/"
-COLLECTFAST_STRATEGY = "collectfast.strategies.boto3.Boto3Strategy"
-STATIC_URL = f"https://{aws_s3_domain}/static/"
+# # STORAGES
+# # ------------------------------------------------------------------------------
+# # https://django-storages.readthedocs.io/en/latest/#installation
+# INSTALLED_APPS += ["storages"]
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_ACCESS_KEY_ID = env("DJANGO_AWS_ACCESS_KEY_ID")
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY")
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_BUCKET_NAME")
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_QUERYSTRING_AUTH = False
+# # DO NOT change these unless you know what you're doing.
+# _AWS_EXPIRY = 60 * 60 * 24 * 7
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_S3_OBJECT_PARAMETERS = {
+# "CacheControl": f"max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate",
+# }
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_S3_MAX_MEMORY_SIZE = env.int(
+# "DJANGO_AWS_S3_MAX_MEMORY_SIZE",
+# default=100_000_000, # 100MB
+# )
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_S3_REGION_NAME = env("DJANGO_AWS_S3_REGION_NAME", default=None)
+# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#cloudfront
+# AWS_S3_CUSTOM_DOMAIN = env("DJANGO_AWS_S3_CUSTOM_DOMAIN", default=None)
+# aws_s3_domain = AWS_S3_CUSTOM_DOMAIN or f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com"
+# # STATIC & MEDIA
+# # ------------------------
+# STORAGES = {
+# "default": {
+# "BACKEND": "django.core.files.storage.FileSystemStorage",
+# },
+# "staticfiles": {
+# "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
+# },
+# }
+# MEDIA_URL = f"https://{aws_s3_domain}/media/"
+# COLLECTFAST_STRATEGY = "collectfast.strategies.boto3.Boto3Strategy"
+# STATIC_URL = f"https://{aws_s3_domain}/static/"
# EMAIL
# ------------------------------------------------------------------------------
@@ -180,27 +174,27 @@ LOGGING = {
},
}
-# Sentry
-# ------------------------------------------------------------------------------
-SENTRY_DSN = env("SENTRY_DSN")
-SENTRY_LOG_LEVEL = env.int("DJANGO_SENTRY_LOG_LEVEL", logging.INFO)
-
-sentry_logging = LoggingIntegration(
- level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs
- event_level=logging.ERROR, # Send errors as events
-)
-integrations = [
- sentry_logging,
- DjangoIntegration(),
- CeleryIntegration(),
- RedisIntegration(),
-]
-sentry_sdk.init(
- dsn=SENTRY_DSN,
- integrations=integrations,
- environment=env("SENTRY_ENVIRONMENT", default="production"),
- traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=0.0),
-)
+# # Sentry
+# # ------------------------------------------------------------------------------
+# SENTRY_DSN = env("SENTRY_DSN")
+# SENTRY_LOG_LEVEL = env.int("DJANGO_SENTRY_LOG_LEVEL", logging.INFO)
+
+# sentry_logging = LoggingIntegration(
+# level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs
+# event_level=logging.ERROR, # Send errors as events
+# )
+# integrations = [
+# sentry_logging,
+# DjangoIntegration(),
+# CeleryIntegration(),
+# RedisIntegration(),
+# ]
+# sentry_sdk.init(
+# dsn=SENTRY_DSN,
+# integrations=integrations,
+# environment=env("SENTRY_ENVIRONMENT", default="production"),
+# traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=0.0),
+# )
# Your stuff...