forked from mozilla-releng/balrog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublic.wsgi
61 lines (51 loc) · 2.44 KB
/
public.wsgi
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
57
58
59
60
61
import logging
import os
from auslib.log import configure_logging
from auslib.web.base import sentry
SYSTEM_ACCOUNTS = ["ffxbld", "tbirdbld", "b2gbld", "stage-ffxbld", "stage-tbirdbld", "stage-b2gbld"]
SPECIAL_FORCE_HOSTS = ["http://download.mozilla.org"]
DOMAIN_WHITELIST = {
"download.mozilla.org": ("Firefox", "Fennec", "Thunderbird"),
"archive.mozilla.org": ("Firefox", "Fennec", "Thunderbird"),
"download.cdn.mozilla.net": ("Firefox", "Fennec"),
"mozilla-nightly-updates.s3.amazonaws.com": ("Firefox",),
"ciscobinary.openh264.org": ("OpenH264",),
"cdmdownload.adobe.com": ("CDM",),
"clients2.googleusercontent.com": ("Widevine",),
"redirector.gvt1.com": ("Widevine",),
"ftp.mozilla.org": ("SystemAddons",),
}
# Logging needs to be set-up before importing the application to make sure that
# logging done from other modules uses our Logger.
logging_kwargs = {
"level": os.environ.get("LOG_LEVEL", logging.INFO)
}
if os.environ.get("LOG_FORMAT") == "plain":
logging_kwargs["formatter"] = logging.Formatter
configure_logging(**logging_kwargs)
from auslib.global_state import cache, dbo
from auslib.web.base import app as application
cache.make_cache("blob", 500, 3600)
# There's probably no no need to ever expire items in the blob schema cache
# at all because they only change during deployments (and new instances of the
# apps will be created at that time, with an empty cache).
# Our cache doesn't support never expiring items, so we have set something.
cache.make_cache("blob_schema", 50, 24 * 60 * 60)
cache.make_cache("blob_version", 500, 60)
# 500 is probably a bit oversized for the rules cache, but the items are so
# small there sholudn't be any negative effect.
cache.make_cache("rules", 500, 30)
dbo.setDb(os.environ["DBURI"])
dbo.setDomainWhitelist(DOMAIN_WHITELIST)
application.config["WHITELISTED_DOMAINS"] = DOMAIN_WHITELIST
application.config["SPECIAL_FORCE_HOSTS"] = SPECIAL_FORCE_HOSTS
# version.json is created when the Docker image is built, and contains details
# about the current code (version number, commit hash), but doesn't exist in
# the repo itself
application.config["VERSION_FILE"] = "/app/version.json"
if os.environ.get('SENTRY_DSN'):
application.config['SENTRY_DSN'] = os.environ.get('SENTRY_DSN')
from auslib.web.base import sentry
sentry.init_app(application, register_signal=False)
if os.environ.get("CACHE_CONTROL"):
application.config["CACHE_CONTROL"] = os.environ["CACHE_CONTROL"]