1
0
Fork 0

Merge pull request #95 from mouse-reeve/docker

Docker
This commit is contained in:
Mouse Reeve 2020-03-28 11:37:17 -07:00 committed by GitHub
commit 6fadf22a54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 124 additions and 12 deletions

View file

@ -0,0 +1,8 @@
from __future__ import absolute_import, unicode_literals
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app
__all__ = ('celery_app',)

24
fedireads/celery.py Normal file
View file

@ -0,0 +1,24 @@
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fedireads.settings')
app = Celery('fedireads')
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))

View file

@ -17,11 +17,16 @@ SECRET_KEY = env('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool('DEBUG', True)
# TODO: annoying that I keep changing and re-commiting this
DOMAIN = env('DOMAIN')
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', ['*'])
OL_URL = env('OL_URL')
# celery/rebbitmq
CELERY_BROKER_URL = env('CELERY_BROKER')
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_BACKEND = 'amqp'
# Application definition
INSTALLED_APPS = [
@ -33,6 +38,7 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'django.contrib.humanize',
'fedireads',
'celery',
]
MIDDLEWARE = [
@ -75,10 +81,10 @@ FEDIREADS_DATABASE_BACKEND = env('FEDIREADS_DATABASE_BACKEND', 'postgres')
FEDIREADS_DBS = {
'postgres': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'fedireads',
'USER': 'fedireads',
'PASSWORD': 'fedireads',
'HOST': '',
'NAME': env('POSTGRES_DB', 'fedireads'),
'USER': env('POSTGRES_USER', 'fedireads'),
'PASSWORD': env('POSTGRES_PASSWORD', 'fedireads'),
'HOST': 'db',
'PORT': 5432
},
'sqlite': {
@ -91,6 +97,7 @@ DATABASES = {
'default': FEDIREADS_DBS[FEDIREADS_DATABASE_BACKEND]
}
LOGIN_URL = '/login/'
AUTH_USER_MODEL = 'fedireads.User'