Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django celery dj1.11 #1

Open
wants to merge 4 commits into
base: django-celery
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ RUN apt-get update && apt-get -y install \
&& apt-get clean

RUN pip install --no-cache-dir \
celery==3.1.17 \
Django==1.8.18 \
celery==3.1.26.post2 \
Django==1.11.16 \
django-celery \
envparse \
gevent \
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
django:
image: gohitech/django:djcelery
image: monashmerc/django:djcelery-dj1.11
build: .
environment:
- DJANGO_ADMINS=[('John', '[email protected]'), ('Mary', '[email protected]')]
Expand All @@ -15,23 +15,23 @@ services:
volumes:
- ./share:/share
celery:
image: gohitech/django:djcelery
image: monashmerc/django:djcelery-dj1.11
command: --loglevel=INFO --autoreload
environment:
- CELERY_ENABLE=True
- POSTGRES_PASSWORD=password
links:
- db
beat:
image: gohitech/django:djcelery
image: monashmerc/django:djcelery-dj1.11
command: --loglevel=INFO
environment:
- CELERY_ENABLE=beat
- POSTGRES_PASSWORD=password
links:
- db
other:
image: gohitech/django:djcelery
image: monashmerc/django:djcelery-dj1.11
command: ["tail","-f","/dev/null",]
environment:
- GUNICORN_ENABLE=False
Expand Down
44 changes: 23 additions & 21 deletions settings.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""
Django settings for Docker image.

Derived from settings generated by 'django-admin startproject' using Django 1.8.18.
Generated by 'django-admin startproject' using Django 1.11.16.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
https://docs.djangoproject.com/en/1.11/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

import sys
import socket
Expand All @@ -26,7 +26,7 @@
import djcelery

try:
from settings_pre import *
from settings_pre import * # pylint: disable=wildcard-import,unused-wildcard-import
except ImportError:
pass

Expand All @@ -48,7 +48,9 @@ def _gethostbyname(hostname):
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY', '+hzj(tw!bod_*_xh4u2ml!ylbtx6)2r9bqq2i!evjo!x&pay%2')

# https://docs.djangoproject.com/en/1.8/howto/static-files/
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")

Expand All @@ -58,19 +60,19 @@ def _gethostbyname(hostname):


# Get all Environment variables with a DJANGO_ prefix; remove prefix
#print { k: v for k, v in os.environ.iteritems() if k.startswith('DJANGO_') }
_django_environ = { k[7:]: v for k, v in os.environ.iteritems() if k.startswith('DJANGO_') }
#print {k: v for k, v in os.environ.iteritems() if k.startswith('DJANGO_')}
_django_environ = {k[7:]: v for k, v in os.environ.iteritems() if k.startswith('DJANGO_')}
for key in _django_environ:
try:
if (key in {'PROJECT_NAME','SETTINGS_MODULE',}) or (key.startswith('DATABASE_')):
if (key in {'PROJECT_NAME', 'SETTINGS_MODULE',}) or (key.startswith('DATABASE_')):
pass
elif key in {'ADMINS','MANAGERS',}:
elif key in {'ADMINS', 'MANAGERS',}:
setattr(this_module, key, tuple(literal_eval(_django_environ[key])))
else:
setattr(this_module, key, literal_eval(_django_environ[key]))
except ValueError,e:
except ValueError as err:
setattr(this_module, key, _django_environ[key])
#print "ValueError for %s: %s (%s)" % (key,_django_environ[key],str(e))
#print "ValueError for %s: %s (%s)" % (key,_django_environ[key],str(err))

# Logging

Expand All @@ -86,7 +88,7 @@ def _gethostbyname(hostname):
'loggers': {
'django': {
'handlers': ['console',],
'level': os.getenv('DJANGO_LOG_LEVEL','INFO'),
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
},
},
}
Expand All @@ -103,7 +105,7 @@ def _gethostbyname(hostname):
)
INSTALLED_APPS += ("djcelery", )

MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down Expand Up @@ -131,16 +133,16 @@ def _gethostbyname(hostname):
]

# CACHES and Database
# https://docs.djangoproject.com/en/1.8/topics/cache/
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
# https://docs.djangoproject.com/en/1.11/topics/cache/
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
# https://hub.docker.com/_/postgres/
if _gethostbyname('db') and os.getenv('POSTGRES_PASSWORD') is not None:
if os.getenv('POSTGRES_PASSWORD') is not None:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.getenv('POSTGRES_DB', os.getenv('POSTGRES_USER','postgres')),
'USER': os.getenv('POSTGRES_USER','postgres'),
'NAME': os.getenv('POSTGRES_DB', os.getenv('POSTGRES_USER', 'postgres')),
'USER': os.getenv('POSTGRES_USER', 'postgres'),
'PASSWORD': os.getenv('POSTGRES_PASSWORD'),
'HOST': 'db',
'PORT': '5432',
Expand Down Expand Up @@ -176,13 +178,13 @@ def _gethostbyname(hostname):
"""

# Provide overrides in settings.d/*.py
config_files = glob.glob(os.path.join(os.getenv('DJANGO_PROJECT_NAME', 'gohitech'),'settings.d','*.py'))
#config_files = glob.glob(os.path.join(BASE_DIR,'settings.d','*.py'))
config_files = glob.glob(os.path.join(os.getenv('DJANGO_PROJECT_NAME', 'gohitech'), 'settings.d', '*.py'))
#config_files = glob.glob(os.path.join(BASE_DIR, 'settings.d', '*.py'))
try:
for config_f in sorted(config_files):
print "INFO: Execute config file %s" % os.path.abspath(config_f)
execfile(os.path.abspath(config_f))
except TypeError,e:
except TypeError:
pass

print "djcelery.setup_loader()"
Expand Down