This commit is contained in:
Rob Hudson 2018-02-02 10:44:30 -08:00
Родитель 5283d9cb92
Коммит 45da721927
4 изменённых файлов: 3 добавлений и 41 удалений

Просмотреть файл

@ -3,6 +3,7 @@ dj-database-url==0.4.2
Django==1.10.8
djangorestframework==3.6.3
google-api-python-client==1.6.2
dockerflow==2017.11.0
gunicorn==19.7.1
httplib2==0.10.3
oauth2client==4.1.2

Просмотреть файл

@ -40,6 +40,7 @@ INSTALLED_APPS = [
'rest_framework',
'viewer.api',
'viewer.core',
'dockerflow.django',
]
MIDDLEWARE_CLASSES = [
@ -51,6 +52,7 @@ MIDDLEWARE_CLASSES = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'dockerflow.django.middleware.DockerflowMiddleware',
]
ROOT_URLCONF = 'viewer.urls'

Просмотреть файл

@ -3,7 +3,6 @@ from django.contrib.auth.decorators import login_required
from django.contrib.auth import views as auth_views
from django.views.generic import TemplateView
from . import views
from .admin import admin_site
from .api.views import login_view, metric, metrics, verify_google_token
@ -18,11 +17,6 @@ urlpatterns = [
url(r'^verify_google_token/$', verify_google_token,
name='verify_google_token'),
# Cloudops URL requirements.
url(r'^__version__', views.ops_version, name='ops-version'),
url(r'^__heartbeat__', views.ops_heartbeat, name='ops-heartbeat'),
url(r'^__lbheartbeat__', views.ops_lbheartbeat, name='ops-lbheartbeat'),
# The catch-all.
url(r'.*', login_required(TemplateView.as_view(
template_name='viewer/index.html')), name='index'),

Просмотреть файл

@ -1,35 +0,0 @@
import json
import os.path
from django.conf import settings
from django.http import HttpResponse, HttpResponseServerError, JsonResponse
from .api.models import Metric
def ops_lbheartbeat(request):
return HttpResponse('ok')
def ops_heartbeat(request):
try:
# Check the database by counting Metrics.
Metric.objects.count()
# TODO: Add checks for other dependencies as we add them
return HttpResponse('ok')
except:
return HttpResponseServerError('database failure')
def ops_version(request):
# TODO: Generate this via TravisCI.
VERSION_FN = '%s/version.json' % settings.BASE_DIR
if os.path.exists(VERSION_FN):
data = json.load(open(VERSION_FN, 'r'))
else:
data = {
"source": "https://github.com/mozilla/distribution-viewer.git",
"version": "dev",
"commit": "dev"
}
return JsonResponse(data)