From 6de51a102ae0d3fd61d1e9a14efc5cd7eec70c8e Mon Sep 17 00:00:00 2001 From: shenry Date: Tue, 22 Sep 2015 02:37:37 -0700 Subject: [PATCH] Edit AWS settings and Add in RollBar support --- docs/deployment-on-heroku.rst | 2 ++ docs/settings.rst | 3 +++ {{cookiecutter.repo_name}}/config/settings/common.py | 9 +++++++++ {{cookiecutter.repo_name}}/config/settings/local.py | 11 +++++++++++ .../config/settings/production.py | 11 +++++++++++ {{cookiecutter.repo_name}}/env.example | 3 ++- 6 files changed, 38 insertions(+), 1 deletion(-) diff --git a/docs/deployment-on-heroku.rst b/docs/deployment-on-heroku.rst index 6ee99fee2..23ec67ea2 100644 --- a/docs/deployment-on-heroku.rst +++ b/docs/deployment-on-heroku.rst @@ -27,6 +27,8 @@ You can either push the 'deploy' button in your generated README.rst or run thes heroku config:set DJANGO_MAILGUN_SERVER_NAME=YOUR_MALGUN_SERVER heroku config:set DJANGO_MAILGUN_API_KEY=YOUR_MAILGUN_API_KEY + heroku config:set DJANGO_ROLLBAR_ACCESS_TOKEN=YOUR_ROLLBAR_ACCESS_TOKEN + heroku config:set PYTHONHASHSEED=random git push heroku master diff --git a/docs/settings.rst b/docs/settings.rst index 0c36df1cd..8b98ab0be 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -34,9 +34,12 @@ Environment Variable Django Setting Development DJANGO_AWS_ACCESS_KEY_ID AWS_ACCESS_KEY_ID n/a raises error DJANGO_AWS_SECRET_ACCESS_KEY AWS_SECRET_ACCESS_KEY n/a raises error DJANGO_AWS_STORAGE_BUCKET_NAME AWS_STORAGE_BUCKET_NAME n/a raises error +DJANGO_AWS_S3_LOCATION AWS_S3_LOCATION n/a us-west-2 +DJANGO_AWS_S3_HOST AWS_S3_HOST n/a s3-us-west-2.amazonaws.com DJANGO_SENTRY_DSN SENTRY_DSN n/a raises error DJANGO_SENTRY_CLIENT SENTRY_CLIENT n/a raven.contrib.django.raven_compat.DjangoClient DJANGO_SENTRY_LOG_LEVEL SENTRY_LOG_LEVEL n/a logging.INFO DJANGO_MAILGUN_API_KEY MAILGUN_ACCESS_KEY n/a raises error DJANGO_MAILGUN_SERVER_NAME MAILGUN_SERVER_NAME n/a raises error +DJANGO_ROLLBAR_ACCESS_TOKEN ROLLBAR['access_token'] raises error raises error ======================================= =========================== ============================================== ====================================================================== diff --git a/{{cookiecutter.repo_name}}/config/settings/common.py b/{{cookiecutter.repo_name}}/config/settings/common.py index 575bb6fdf..4540c0611 100644 --- a/{{cookiecutter.repo_name}}/config/settings/common.py +++ b/{{cookiecutter.repo_name}}/config/settings/common.py @@ -68,6 +68,15 @@ MIGRATION_MODULES = { 'sites': '{{ cookiecutter.repo_name }}.contrib.sites.migrations' } +# ROLLBAR CONFIGURATION +# ------------------------------------------------------------------------------ +# We have to set the other settings in the child files to make sure we have +# rollbar at the end of MIDDLEWARE_CLASSES +ROLLBAR = { + 'access_token': env('ROLLBAR_ACCESS_TOKEN'), + 'root': str(ROOT_DIR), +} + # DEBUG # ------------------------------------------------------------------------------ # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug diff --git a/{{cookiecutter.repo_name}}/config/settings/local.py b/{{cookiecutter.repo_name}}/config/settings/local.py index cbe5d58db..f5c776771 100644 --- a/{{cookiecutter.repo_name}}/config/settings/local.py +++ b/{{cookiecutter.repo_name}}/config/settings/local.py @@ -67,3 +67,14 @@ CELERY_ALWAYS_EAGER = True ########## END CELERY {% endif %} # Your local stuff: Below this line define 3rd party library settings + +# ROLLBAR CONFIG WITH BRANCH GRAB +# ------------------------------------------------------------------------------ +from subprocess import Popen, PIPE +conn = Popen(["git", "rev-parse", "--symbolic-full-name", "--abbrev-ref", "HEAD"],stdout=PIPE) +branch = bytes.decode(conn.stdout.read(), 'utf-8').strip() +ROLLBAR['branch'] = branch +ROLLBAR['enviroment'] = 'development' +# must be last +MIDDLEWARE_CLASSES += ('rollbar.contrib.django.middleware.RollbarNotifierMiddleware',) + diff --git a/{{cookiecutter.repo_name}}/config/settings/production.py b/{{cookiecutter.repo_name}}/config/settings/production.py index 7c9fc4006..55cb7f65e 100644 --- a/{{cookiecutter.repo_name}}/config/settings/production.py +++ b/{{cookiecutter.repo_name}}/config/settings/production.py @@ -8,6 +8,7 @@ Production Configurations - Use Redis on Heroku {% if cookiecutter.use_sentry == "y" %} - Use sentry for error logging +- Use Rollbar for performance management {% endif %} ''' from __future__ import absolute_import, unicode_literals @@ -89,8 +90,11 @@ AWS_SECRET_ACCESS_KEY = env('DJANGO_AWS_SECRET_ACCESS_KEY') AWS_STORAGE_BUCKET_NAME = env('DJANGO_AWS_STORAGE_BUCKET_NAME') AWS_AUTO_CREATE_BUCKET = True AWS_QUERYSTRING_AUTH = False +AWS_S3_LOCATION = env('DJANGO_AWS_S3_LOCATION', 'us-west-2') +AWS_S3_HOST = env('DJANGO_AWS_S3_HOST', 's3-us-west-2.amazonaws.com') AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat() +MEDIA_URL = 'https://s3.amazonaws.com/%s/cookiecutter-django/' % AWS_STORAGE_BUCKET_NAME # AWS cache settings, don't change unless you know what you're doing: AWS_EXPIRY = 60 * 60 * 24 * 7 @@ -218,3 +222,10 @@ RAVEN_CONFIG = { } {% endif %} # Your production stuff: Below this line define 3rd party library settings + +# ROLLBAR CONFIG +# ------------------------------------------------------------------------------ +ROLLBAR['branch'] = master +ROLLBAR['enviroment'] = 'production' +# must be last +MIDDLEWARE_CLASSES += ('rollbar.contrib.django.middleware.RollbarNotifierMiddleware',) diff --git a/{{cookiecutter.repo_name}}/env.example b/{{cookiecutter.repo_name}}/env.example index 381a3cf0b..9d4c443b0 100644 --- a/{{cookiecutter.repo_name}}/env.example +++ b/{{cookiecutter.repo_name}}/env.example @@ -9,5 +9,6 @@ DJANGO_AWS_SECRET_ACCESS_KEY= DJANGO_AWS_STORAGE_BUCKET_NAME= DJANGO_MAILGUN_API_KEY= DJANGO_MAILGUN_SERVER_NAME= +DJANGO_ROLLBAR_ACCESS_TOKEN= DJANGO_SERVER_EMAIL= -DJANGO_SECURE_SSL_REDIRECT=False \ No newline at end of file +DJANGO_SECURE_SSL_REDIRECT=False