Skip to content

Bootstrapping Sentry environment like the FAQ #1003

@taylortrimble

Description

@taylortrimble

Hey there! I'm making a small Docker container for Sentry. So far, I've had good luck! I can get Sentry running with queuing, cacheing, postgresql, …

The last piece I'm missing is adding a superuser non-interactively!

There's a great example at http://sentry.readthedocs.org/en/latest/faq/index.html#how-do-i, which I have modified for my purposes to be:

#!/usr/bin/env python

# Bootstrap the Sentry environment
from sentry.utils.runner import configure
from django.db import connections
configure()

# Add default superuser
from sentry.models import User

user = User()
user.username = 'admin'
user.email = 'admin@localhost'
user.is_superuser = True
user.set_password('admin')
user.save()

I added the from django.db import connections line to deal with another error, but my overall problem is this: I have SENTRY_CONF set to the file I need it to be, but configure() doesn't seem to be bootstrapping all of Sentry. Specifically, it seems like Django settings aren't ready:

Step 23 : RUN chmod a+x /root/configure_sentry.sh && /root/configure_sentry.sh
 ---> Running in 187ba459e139
 * Starting PostgreSQL 9.1 database server
   ...done.
CREATE ROLE
CREATE DATABASE
Traceback (most recent call last):
  File "/root/create_superuser.py", line 5, in <module>
    from django.db import connections
  File "/usr/local/lib/python2.7/dist-packages/Django-1.5.4-py2.7.egg/django/db/__init__.py", line 11, in <module>
    if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/usr/local/lib/python2.7/dist-packages/Django-1.5.4-py2.7.egg/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.5.4-py2.7.egg/django/conf/__init__.py", line 46, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Error build: The command [/bin/sh -c chmod a+x /root/configure_sentry.sh && /root/configure_sentry.sh] returned a non-zero code: 1
The command [/bin/sh -c chmod a+x /root/configure_sentry.sh && /root/configure_sentry.sh] returned a non-zero code: 1

(That's some Docker output and a stack trace)

@dcramer, it looks like you added the documentation not in b421eca. Perhaps you'd be able to help?

I really am a Python newbie at heart, and would appreciate any help I can get on what I'm sure is a simple concept I'm missing. Thanks, all!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions