Add sentry and fabfile

This commit is contained in:
Nikolai R Kristiansen committed 2018-03-17 13:59:04 +01:00
1 parent cd11bd580b
commit 90eae21bc7
4 files changed
+100 -5

No files matched your search

+47 -4
View File
@@ -73,7 +73,7 @@ MIDDLEWARE_CLASSES = (
ROOT_URLCONF = 'bbssite.urls' ROOT_URLCONF = 'bbssite.urls'
INSTALLED_APPS = ( INSTALLED_APPS = [
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sessions',
@@ -87,10 +87,11 @@ INSTALLED_APPS = (
'django_extensions', 'django_extensions',
'rest_framework', 'rest_framework',
'easy_thumbnails', 'easy_thumbnails',
) 'raven.contrib.django.raven_compat',
LOCAL_APPS = ( ]
LOCAL_APPS = [
'main', 'main',
) ]
INSTALLED_APPS += LOCAL_APPS INSTALLED_APPS += LOCAL_APPS
LOGIN_REDIRECT_URL = '/' LOGIN_REDIRECT_URL = '/'
@@ -108,6 +109,48 @@ THUMBNAIL_ALIASES = {
}, },
} }
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'root': {
'level': 'INFO',
'handlers': ['console', 'sentry'],
},
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
},
'handlers': {
'sentry': {
'level': 'WARNING',
'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
}
},
'loggers': {
'django.db.backends': {
'level': 'ERROR',
'handlers': ['console'],
'propagate': False,
},
'raven': {
'level': 'WARNING',
'handlers': ['console'],
'propagate': False,
},
'sentry.errors': {
'level': 'WARNING',
'handlers': ['console'],
'propagate': False,
},
},
}
try: try:
from .local_settings import * from .local_settings import *
except ImportError: except ImportError:
+3 -1
View File
@@ -1,6 +1,8 @@
import os import os
from django.core.wsgi import get_wsgi_application
from raven.contrib.django.middleware.wsgi import Sentry
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bbssite.settings') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bbssite.settings')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application() application = get_wsgi_application()
application = Sentry(application)
Vendored
+49
View File
@@ -0,0 +1,49 @@
import os
from contextlib import contextmanager as _contextmanager
from fabric.api import run, sudo, env, cd, prefix
env.use_ssh_config = True
env.hosts = ['dreamcast.neuf.no']
env.user = 'gitdeploy'
BASE_PATH = '/var/www/neuf.no/'
PROJECTS = {
'bbs': {
'path': os.path.join(BASE_PATH, 'bbs'),
'process_name': 'bbs.neuf.no'
},
'fantastene': {
'path': os.path.join(BASE_PATH, 'bbs_fantastene'),
'process_name': 'fantastene-bbs.neuf.no'
},
'arrut': {
'path': os.path.join(BASE_PATH, 'bbs_arrut'),
'process_name': 'arrut-bbs.neuf.no'
}
}
@_contextmanager
def virtualenv(project):
activate = 'source {}/venv/bin/activate'.format(project['path'])
with cd(project['path']), prefix(activate):
yield
def deploy(project_name='bbs'):
if project_name not in PROJECTS:
print("'{}' not in valid projects({})".format(project_name, ', '.join(sorted(PROJECTS.keys()))))
exit(1)
project = PROJECTS[project_name]
with virtualenv(project):
run('git pull') # Get source
run('pip install -r requirements.txt') # install deps in virtualenv
run('umask 022; python manage.py collectstatic --noinput') # Collect static
run('python manage.py migrate') # Run DB migrations
# Reload
sudo('/usr/bin/supervisorctl pid {process_name} | xargs kill -HUP'.format(process_name=project['process_name']),
shell=False)
+1
View File
@@ -8,3 +8,4 @@ gunicorn==19.7.1
mysqlclient==1.3.12 mysqlclient==1.3.12
djangorestframework==3.6.4 djangorestframework==3.6.4
Pillow==5.0.0 Pillow==5.0.0
raven==6.6.0