~james-w/python-oops-tools/prod-deploy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import sys

paths = [${string-paths}]

for path in paths:
    if path not in sys.path:
        # Insert the path in sys.path to guarantee eggs are used instead of
        # system packages.
        sys.path.insert(0, path)
os.environ['DJANGO_SETTINGS_MODULE'] = "oopstools.settings"

import django.core.handlers.wsgi
from oops_wsgi.django import OOPSWSGIHandler

application = OOPSWSGIHandler()
from timeline_django.wsgi import make_app as timeline_django_make_app
from timeline import wsgi as timeline_wsgi
pplication = timeline_django_make_app(application)
application = timeline_wsgi.make_app(application)

from timeline_django import setup
setup.setup_for_requests()

# Report OOPSes back to us.
from functools import partial
from oops import Config
from oops_wsgi import make_app, install_hooks
# Transports - AMQP live (dev only service, no need for fallback transport)
from oops_amqp import Publisher
from amqplib import client_0_8 as amqp

from django.conf import settings

config = Config()
config.template['reporter'] = '${configuration:oops-web-amqp-reporter}'
install_hooks(config)

# Attach the timeline to error reports
import oops_timeline
import timeline_django.filters
oops_timeline.install_hooks(config)
timeline_django.filters.install_hooks(config)

# Can add custom filters / hooks if needed - see docs.
factory = partial(amqp.Connection, host=settings.OOPS_WEB_AMQP_HOST,
    userid=settings.OOPS_WEB_AMQP_USER,
    password=settings.OOPS_WEB_AMQP_PASSWORD,
    virtual_host=settings.OOPS_WEB_AMQP_VHOST, insist=False)
publisher = Publisher(
    factory, settings.OOPS_WEB_AMQP_EXCHANGE, settings.OOPS_WEB_AMQP_ROUTING)
config.publishers.append(publisher)

# finally we can wrap the app with OOPS reporting
application = make_app(application, config, oops_on_status=['500'],
    soft_start_timeout=20000)