def initialize_app(config, skip_service_validation=False):
    settings = config['settings']

    bootstrap_options(settings, config['options'])

    configure_structlog()

    if 'south' in settings.INSTALLED_APPS:
        fix_south(settings)

    apply_legacy_settings(settings)

    bind_cache_to_option_store()

    # Commonly setups don't correctly configure themselves for production envs
    # so lets try to provide a bit more guidance
    if settings.CELERY_ALWAYS_EAGER and not settings.DEBUG:
        warnings.warn(
            'Sentry is configured to run asynchronous tasks in-process. '
            'This is not recommended within production environments. '
            'See https://docs.sentry.io/on-premise/server/queue/ for more information.'
        )

    if settings.SENTRY_SINGLE_ORGANIZATION:
        settings.SENTRY_FEATURES['organizations:create'] = False

    if not hasattr(settings, 'SUDO_COOKIE_SECURE'):
        settings.SUDO_COOKIE_SECURE = getattr(settings, 'SESSION_COOKIE_SECURE', False)
    if not hasattr(settings, 'SUDO_COOKIE_DOMAIN'):
        settings.SUDO_COOKIE_DOMAIN = getattr(settings, 'SESSION_COOKIE_DOMAIN', None)
    if not hasattr(settings, 'SUDO_COOKIE_PATH'):
        settings.SUDO_COOKIE_PATH = getattr(settings, 'SESSION_COOKIE_PATH', '/')

    if not hasattr(settings, 'CSRF_COOKIE_SECURE'):
        settings.CSRF_COOKIE_SECURE = getattr(settings, 'SESSION_COOKIE_SECURE', False)
    if not hasattr(settings, 'CSRF_COOKIE_DOMAIN'):
        settings.CSRF_COOKIE_DOMAIN = getattr(settings, 'SESSION_COOKIE_DOMAIN', None)
    if not hasattr(settings, 'CSRF_COOKIE_PATH'):
        settings.CSRF_COOKIE_PATH = getattr(settings, 'SESSION_COOKIE_PATH', '/')

    settings.CACHES['default']['VERSION'] = settings.CACHE_VERSION

    settings.ASSET_VERSION = get_asset_version(settings)
    settings.STATIC_URL = settings.STATIC_URL.format(
        version=settings.ASSET_VERSION,
    )

    register_plugins(settings)

    initialize_receivers()

    validate_options(settings)

    setup_services(validate=not skip_service_validation)

    from django.utils import timezone
    from sentry.app import env
    from sentry.runner.settings import get_sentry_conf
    env.data['config'] = get_sentry_conf()
    env.data['start_date'] = timezone.now()
Exemple #2
0
def initialize_app(config, skip_backend_validation=False):
    settings = config['settings']

    bootstrap_options(settings, config['options'])

    configure_structlog()

    fix_south(settings)

    apply_legacy_settings(settings)

    bind_cache_to_option_store()

    install_plugin_apps(settings)

    # Commonly setups don't correctly configure themselves for production envs
    # so lets try to provide a bit more guidance
    if settings.CELERY_ALWAYS_EAGER and not settings.DEBUG:
        warnings.warn(
            'Sentry is configured to run asynchronous tasks in-process. '
            'This is not recommended within production environments. '
            'See https://docs.getsentry.com/on-premise/server/queue/ for more information.'
        )

    if settings.SENTRY_SINGLE_ORGANIZATION:
        settings.SENTRY_FEATURES['organizations:create'] = False

    settings.SUDO_COOKIE_SECURE = getattr(settings, 'SESSION_COOKIE_SECURE',
                                          False)
    settings.SUDO_COOKIE_DOMAIN = getattr(settings, 'SESSION_COOKIE_DOMAIN',
                                          None)
    settings.SUDO_COOKIE_PATH = getattr(settings, 'SESSION_COOKIE_PATH', '/')

    settings.CSRF_COOKIE_SECURE = getattr(settings, 'SESSION_COOKIE_SECURE',
                                          False)
    settings.CSRF_COOKIE_DOMAIN = getattr(settings, 'SESSION_COOKIE_DOMAIN',
                                          None)
    settings.CSRF_COOKIE_PATH = getattr(settings, 'SESSION_COOKIE_PATH', '/')

    settings.CACHES['default']['VERSION'] = settings.CACHE_VERSION

    settings.ASSET_VERSION = get_asset_version(settings)
    settings.STATIC_URL = settings.STATIC_URL.format(
        version=settings.ASSET_VERSION, )

    register_plugins(settings)

    initialize_receivers()

    validate_options(settings)

    if not skip_backend_validation:
        validate_backends()

    from django.utils import timezone
    from sentry.app import env
    from sentry.runner.settings import get_sentry_conf
    env.data['config'] = get_sentry_conf()
    env.data['start_date'] = timezone.now()
Exemple #3
0
def initialize_app(config, skip_backend_validation=False):
    settings = config["settings"]

    bootstrap_options(settings, config["options"])

    fix_south(settings)

    apply_legacy_settings(settings)

    bind_cache_to_option_store()

    install_plugin_apps(settings)

    # Commonly setups don't correctly configure themselves for production envs
    # so lets try to provide a bit more guidance
    if settings.CELERY_ALWAYS_EAGER and not settings.DEBUG:
        import warnings

        warnings.warn(
            "Sentry is configured to run asynchronous tasks in-process. "
            "This is not recommended within production environments. "
            "See https://docs.getsentry.com/on-premise/server/queue/ for more information."
        )

    if settings.SENTRY_SINGLE_ORGANIZATION:
        settings.SENTRY_FEATURES["organizations:create"] = False

    settings.SUDO_COOKIE_SECURE = getattr(settings, "SESSION_COOKIE_SECURE", False)
    settings.SUDO_COOKIE_DOMAIN = getattr(settings, "SESSION_COOKIE_DOMAIN", None)
    settings.SUDO_COOKIE_PATH = getattr(settings, "SESSION_COOKIE_PATH", "/")

    settings.CSRF_COOKIE_SECURE = getattr(settings, "SESSION_COOKIE_SECURE", False)
    settings.CSRF_COOKIE_DOMAIN = getattr(settings, "SESSION_COOKIE_DOMAIN", None)
    settings.CSRF_COOKIE_PATH = getattr(settings, "SESSION_COOKIE_PATH", "/")

    settings.CACHES["default"]["VERSION"] = settings.CACHE_VERSION

    settings.ASSET_VERSION = get_asset_version(settings)
    settings.STATIC_URL = settings.STATIC_URL.format(version=settings.ASSET_VERSION)

    register_plugins(settings)

    initialize_receivers()

    validate_options(settings)

    if not skip_backend_validation:
        validate_backends()

    from django.utils import timezone
    from sentry.app import env
    from sentry.runner.settings import get_sentry_conf

    env.data["config"] = get_sentry_conf()
    env.data["start_date"] = timezone.now()
Exemple #4
0
def initialize_app(config, skip_service_validation=False):
    settings = config["settings"]

    bootstrap_options(settings, config["options"])

    configure_structlog()

    # Commonly setups don't correctly configure themselves for production envs
    # so lets try to provide a bit more guidance
    if settings.CELERY_ALWAYS_EAGER and not settings.DEBUG:
        warnings.warn(
            "Sentry is configured to run asynchronous tasks in-process. "
            "This is not recommended within production environments. "
            "See https://docs.sentry.io/on-premise/server/queue/ for more information."
        )

    if settings.SENTRY_SINGLE_ORGANIZATION:
        settings.SENTRY_FEATURES["organizations:create"] = False

    if not hasattr(settings, "SUDO_COOKIE_SECURE"):
        settings.SUDO_COOKIE_SECURE = getattr(settings, "SESSION_COOKIE_SECURE", False)
    if not hasattr(settings, "SUDO_COOKIE_DOMAIN"):
        settings.SUDO_COOKIE_DOMAIN = getattr(settings, "SESSION_COOKIE_DOMAIN", None)
    if not hasattr(settings, "SUDO_COOKIE_PATH"):
        settings.SUDO_COOKIE_PATH = getattr(settings, "SESSION_COOKIE_PATH", "/")

    if not hasattr(settings, "CSRF_COOKIE_SECURE"):
        settings.CSRF_COOKIE_SECURE = getattr(settings, "SESSION_COOKIE_SECURE", False)
    if not hasattr(settings, "CSRF_COOKIE_DOMAIN"):
        settings.CSRF_COOKIE_DOMAIN = getattr(settings, "SESSION_COOKIE_DOMAIN", None)
    if not hasattr(settings, "CSRF_COOKIE_PATH"):
        settings.CSRF_COOKIE_PATH = getattr(settings, "SESSION_COOKIE_PATH", "/")

    settings.CACHES["default"]["VERSION"] = settings.CACHE_VERSION

    settings.ASSET_VERSION = get_asset_version(settings)
    settings.STATIC_URL = settings.STATIC_URL.format(version=settings.ASSET_VERSION)

    if getattr(settings, "SENTRY_DEBUGGER", None) is None:
        settings.SENTRY_DEBUGGER = settings.DEBUG

    monkeypatch_model_unpickle()

    import django

    django.setup()

    monkeypatch_django_migrations()

    apply_legacy_settings(settings)

    bind_cache_to_option_store()

    register_plugins(settings)

    initialize_receivers()

    validate_options(settings)

    validate_snuba()

    configure_sdk()

    setup_services(validate=not skip_service_validation)

    from django.utils import timezone
    from sentry.app import env
    from sentry.runner.settings import get_sentry_conf

    env.data["config"] = get_sentry_conf()
    env.data["start_date"] = timezone.now()
Exemple #5
0
def initialize_app(config, skip_service_validation=False):
    settings = config["settings"]

    if settings.DEBUG:
        # Enable line buffering for stderr, TODO(py3.9) can be removed after py3.9, see bpo-13601
        sys.stderr = os.fdopen(sys.stderr.fileno(), "w", 1)
        sys.stdout = os.fdopen(sys.stdout.fileno(), "w", 1)

    # Just reuse the integration app for Single Org / Self-Hosted as
    # it doesn't make much sense to use 2 separate apps for SSO and
    # integration.
    if settings.SENTRY_SINGLE_ORGANIZATION:
        options_mapper.update(
            {
                "github-app.client-id": "GITHUB_APP_ID",
                "github-app.client-secret": "GITHUB_API_SECRET",
            }
        )

    bootstrap_options(settings, config["options"])

    configure_structlog()

    # Commonly setups don't correctly configure themselves for production envs
    # so lets try to provide a bit more guidance
    if settings.CELERY_ALWAYS_EAGER and not settings.DEBUG:
        warnings.warn(
            "Sentry is configured to run asynchronous tasks in-process. "
            "This is not recommended within production environments. "
            "See https://docs.sentry.io/on-premise/server/queue/ for more information."
        )

    if settings.SENTRY_SINGLE_ORGANIZATION:
        settings.SENTRY_FEATURES["organizations:create"] = False

    if not hasattr(settings, "SUDO_COOKIE_SECURE"):
        settings.SUDO_COOKIE_SECURE = getattr(settings, "SESSION_COOKIE_SECURE", False)
    if not hasattr(settings, "SUDO_COOKIE_DOMAIN"):
        settings.SUDO_COOKIE_DOMAIN = getattr(settings, "SESSION_COOKIE_DOMAIN", None)
    if not hasattr(settings, "SUDO_COOKIE_PATH"):
        settings.SUDO_COOKIE_PATH = getattr(settings, "SESSION_COOKIE_PATH", "/")

    if not hasattr(settings, "CSRF_COOKIE_SECURE"):
        settings.CSRF_COOKIE_SECURE = getattr(settings, "SESSION_COOKIE_SECURE", False)
    if not hasattr(settings, "CSRF_COOKIE_DOMAIN"):
        settings.CSRF_COOKIE_DOMAIN = getattr(settings, "SESSION_COOKIE_DOMAIN", None)
    if not hasattr(settings, "CSRF_COOKIE_PATH"):
        settings.CSRF_COOKIE_PATH = getattr(settings, "SESSION_COOKIE_PATH", "/")

    for key in settings.CACHES:
        if not hasattr(settings.CACHES[key], "VERSION"):
            settings.CACHES[key]["VERSION"] = 2

    settings.ASSET_VERSION = get_asset_version(settings)
    settings.STATIC_URL = settings.STATIC_URL.format(version=settings.ASSET_VERSION)

    if getattr(settings, "SENTRY_DEBUGGER", None) is None:
        settings.SENTRY_DEBUGGER = settings.DEBUG

    monkeypatch_model_unpickle()

    import django

    django.setup()

    monkeypatch_django_migrations()

    apply_legacy_settings(settings)

    bind_cache_to_option_store()

    register_plugins(settings)

    initialize_receivers()

    validate_options(settings)

    validate_snuba()

    configure_sdk()

    setup_services(validate=not skip_service_validation)

    from django.utils import timezone
    from sentry.app import env
    from sentry.runner.settings import get_sentry_conf

    env.data["config"] = get_sentry_conf()
    env.data["start_date"] = timezone.now()
Exemple #6
0
def initialize_app(config, skip_service_validation=False):
    settings = config['settings']

    bootstrap_options(settings, config['options'])

    from clims.logs import configure_logging
    configure_logging()

    if 'south' in settings.INSTALLED_APPS:
        fix_south(settings)

    # Commonly setups don't correctly configure themselves for production envs
    # so lets try to provide a bit more guidance
    if settings.CELERY_ALWAYS_EAGER and not settings.DEBUG:
        warnings.warn(
            'Sentry is configured to run asynchronous tasks in-process. '
            'This is not recommended within production environments. '
            'See https://docs.sentry.io/on-premise/server/queue/ for more information.'
        )

    if settings.SENTRY_SINGLE_ORGANIZATION:
        settings.SENTRY_FEATURES['organizations:create'] = False

    if not hasattr(settings, 'SUDO_COOKIE_SECURE'):
        settings.SUDO_COOKIE_SECURE = getattr(settings,
                                              'SESSION_COOKIE_SECURE', False)
    if not hasattr(settings, 'SUDO_COOKIE_DOMAIN'):
        settings.SUDO_COOKIE_DOMAIN = getattr(settings,
                                              'SESSION_COOKIE_DOMAIN', None)
    if not hasattr(settings, 'SUDO_COOKIE_PATH'):
        settings.SUDO_COOKIE_PATH = getattr(settings, 'SESSION_COOKIE_PATH',
                                            '/')

    if not hasattr(settings, 'CSRF_COOKIE_SECURE'):
        settings.CSRF_COOKIE_SECURE = getattr(settings,
                                              'SESSION_COOKIE_SECURE', False)
    if not hasattr(settings, 'CSRF_COOKIE_DOMAIN'):
        settings.CSRF_COOKIE_DOMAIN = getattr(settings,
                                              'SESSION_COOKIE_DOMAIN', None)
    if not hasattr(settings, 'CSRF_COOKIE_PATH'):
        settings.CSRF_COOKIE_PATH = getattr(settings, 'SESSION_COOKIE_PATH',
                                            '/')

    settings.CACHES['default']['VERSION'] = settings.CACHE_VERSION

    settings.ASSET_VERSION = get_asset_version(settings)
    settings.STATIC_URL = settings.STATIC_URL.format(
        version=settings.ASSET_VERSION, )

    import django
    django.setup()

    bind_cache_to_option_store()

    from clims.services.application import ioc, ApplicationService
    app = ApplicationService()
    ioc.set_application(app)
    app.plugins.load_installed()

    initialize_receivers()

    validate_options(settings)

    setup_services(validate=not skip_service_validation)

    from django.utils import timezone
    from sentry.app import env
    from sentry.runner.settings import get_sentry_conf
    env.data['config'] = get_sentry_conf()
    env.data['start_date'] = timezone.now()