Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pbansal
Test-Docker
Commits
821beadb
Commit
821beadb
authored
Aug 20, 2019
by
isillitoe
Browse files
add docs
parent
81c80c01
Changes
3
Hide whitespace changes
Inline
Side-by-side
cathapi/celery.py
View file @
821beadb
"""
Run tasks in the background with Celery
"""
from
__future__
import
absolute_import
,
unicode_literals
import
os
from
celery
import
Celery
...
...
@@ -29,4 +29,5 @@ app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
@
app
.
task
(
bind
=
True
)
def
debug_task
(
self
):
"""Print debug messages"""
print
(
'Request: {0!r}'
.
format
(
self
.
request
))
cathapi/settings/container.py
View file @
821beadb
...
...
@@ -5,51 +5,60 @@ from decouple import config
from
.base
import
*
# Bend the broker to the redis container
BROKER_URL
=
'redis://cathapi-redis:6379'
CELERY_RESULT_BACKEND
=
'redis://cathapi-redis:6379'
# These settings make sure any tasks run in testing
# are run locally with the 'test' database
CELERY_ALWAYS_EAGER
=
True
TEST_RUNNER
=
'djcelery.contrib.test_runner.CeleryTestSuiteRunner'
IS_CELERY
=
config
(
'I_AM_CELERY'
,
default
=
False
,
cast
=
bool
)
if
not
IS_CELERY
:
# These settings are only relevant for Django instances
DEBUG
=
True
# Bend the Django cache to use the redis container
CACHES
[
"default"
][
"LOCATION"
]
=
"redis://cathapi-redis:6379/1"
'''
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': config('PG_NAME', default='cathapi', cast=str),
'USER': config('PG_USER', default='cathapiuser', cast=str),
'PASSWORD': config('POSTGRES_PASSWORD', cast=str),
'HOST': config('PG_HOST', default='postgres', cast=str),
'PORT': config('PG_PORT', default=5432, cast=int),
}
}
'''
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
os
.
path
.
join
(
'/cathapi-data'
,
'db.sqlite3'
),
}
}
INSTALLED_APPS
+=
[
# 'debug_toolbar',
]
STATICFILES_DIRS
=
[
os
.
path
.
join
(
'static/'
),
]
STATIC_ROOT
=
'/static'
#MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware', ]
# These settings are only relevant for Django instances
DEBUG
=
True
# Bend the Django cache to use the redis container
CACHES
[
"default"
][
"LOCATION"
]
=
"redis://cathapi-redis:6379/1"
'''
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': config('PG_NAME', default='cathapi', cast=str),
'USER': config('PG_USER', default='cathapiuser', cast=str),
'PASSWORD': config('POSTGRES_PASSWORD', cast=str),
'HOST': config('PG_HOST', default='postgres', cast=str),
'PORT': config('PG_PORT', default=5432, cast=int),
}
}
'''
# local database config
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
os
.
path
.
join
(
'/cathapi-data'
,
'db.sqlite3'
),
}
}
INSTALLED_APPS
+=
[
# 'debug_toolbar',
]
STATICFILES_DIRS
=
[
os
.
path
.
join
(
'static/'
),
]
STATIC_ROOT
=
'/static'
#MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware', ]
cathapi/settings/prod.py
View file @
821beadb
...
...
@@ -4,8 +4,12 @@ from decouple import config
from
.base
import
*
# turn off debug
DEBUG
=
False
# use PostgreSQL in production
DATABASES
=
{
'default'
:
{
# 'ENGINE': 'django.db.backends.sqlite3',
...
...
@@ -19,6 +23,8 @@ DATABASES = {
}
}
# allowed hosts
ALLOWED_HOSTS
=
[
'.cathdb.info'
,
'orengoapi01'
]
# CACHES = {
...
...
@@ -32,9 +38,11 @@ ALLOWED_HOSTS = ['.cathdb.info', 'orengoapi01']
# }
# }
EMAIL_BACKEND
=
'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST
=
'smtp.mailgun.org'
EMAIL_PORT
=
587
EMAIL_HOST_USER
=
'mytestuser'
EMAIL_HOST_PASSWORD
=
'mytestpassword'
EMAIL_USE_TLS
=
True
# need to set up mailgun
# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# EMAIL_HOST = 'smtp.mailgun.org'
# EMAIL_PORT = 587
# EMAIL_HOST_USER = 'mytestuser'
# EMAIL_HOST_PASSWORD = 'mytestpassword'
# EMAIL_USE_TLS = True
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment