Initial commit to support Celery 4.3.0

Merges 55e9b2263c from versions/next
with code from GitLab issue #594 and GitLab merge request !55.

Thanks to Jakob Haufe (@sur5r) and Jesaja Everling (@jeverling)
for much of the research and code updates.

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-07-17 04:30:11 -04:00
parent 0b42567179
commit ab601f9180
23 changed files with 119 additions and 79 deletions

View File

@@ -258,7 +258,7 @@ test-with-docker-frontend: ## Launch a front end instance that uses the producti
./manage.py runserver --settings=mayan.settings.staging.docker ./manage.py runserver --settings=mayan.settings.staging.docker
test-with-docker-worker: ## Launch a worker instance that uses the production-like services. test-with-docker-worker: ## Launch a worker instance that uses the production-like services.
./manage.py celery worker --settings=mayan.settings.staging.docker -B -l INFO -O fair DJANGO_SETTINGS_MODULE=mayan.settings.staging.docker ./manage.py celery worker -A mayan -B -l INFO -O fair
docker-mysql-on: ## Launch and initialize a MySQL Docker container. docker-mysql-on: ## Launch and initialize a MySQL Docker container.
docker run -d --name mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=True -e MYSQL_DATABASE=mayan_edms mysql docker run -d --name mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=True -e MYSQL_DATABASE=mayan_edms mysql

View File

@@ -4,7 +4,7 @@
# BASE_IMAGE - Bare bones image with the base packages needed to run Mayan EDMS # BASE_IMAGE - Bare bones image with the base packages needed to run Mayan EDMS
#### ####
FROM debian:9.8-slim as BASE_IMAGE FROM debian:10.0-slim as BASE_IMAGE
LABEL maintainer="Roberto Rosario roberto.rosario@mayan-edms.com" LABEL maintainer="Roberto Rosario roberto.rosario@mayan-edms.com"
@@ -29,7 +29,7 @@ apt-get update \
graphviz \ graphviz \
libfuse2 \ libfuse2 \
libmagic1 \ libmagic1 \
libmariadbclient18 \ libmmariadb3 \
libreoffice \ libreoffice \
libpq5 \ libpq5 \
poppler-utils \ poppler-utils \
@@ -96,31 +96,31 @@ apt-get install -y --no-install-recommends \
libssl-dev \ libssl-dev \
g++ \ g++ \
gcc \ gcc \
python-dev \ python3-dev \
python-virtualenv \ python3-venv \
&& mkdir -p "${PROJECT_INSTALL_DIR}" \ && mkdir -p "${PROJECT_INSTALL_DIR}" \
&& chown -R mayan:mayan "${PROJECT_INSTALL_DIR}" \ && chown -R mayan:mayan "${PROJECT_INSTALL_DIR}" \
&& chown -R mayan:mayan /src && chown -R mayan:mayan /src
USER mayan USER mayan
RUN python -m virtualenv "${PROJECT_INSTALL_DIR}" \ RUN python3 -m venv "${PROJECT_INSTALL_DIR}" \
&& . "${PROJECT_INSTALL_DIR}/bin/activate" \ && . "${PROJECT_INSTALL_DIR}/bin/activate" \
&& pip install --no-cache-dir --no-use-pep517 \ && pip install --no-cache-dir \
librabbitmq==1.6.1 \ librabbitmq==2.0.0 \
mysql-python==1.2.5 \ mysqlclient==1.4.2.post1 \
psycopg2==2.7.3.2 \ psycopg2==2.8.3 \
redis==2.10.6 \ redis==3.2.1 \
# psutil is needed by ARM builds otherwise gevent and gunicorn fail to start # psutil is needed by ARM builds otherwise gevent and gunicorn fail to start
&& UNAME=`uname -m` && if [ "${UNAME#*arm}" != $UNAME ]; then \ && UNAME=`uname -m` && if [ "${UNAME#*arm}" != $UNAME ]; then \
pip install --no-cache-dir --no-use-pep517 \ pip install --no-cache-dir \
psutil==5.6.2 \ psutil==5.6.2 \
; fi \ ; fi \
# Install the Python packages needed to build Mayan EDMS # Install the Python packages needed to build Mayan EDMS
&& pip install --no-cache-dir --no-use-pep517 -r /src/requirements/build.txt \ && pip install --no-cache-dir -r /src/requirements/build.txt \
# Build Mayan EDMS # Build Mayan EDMS
&& python setup.py sdist \ && python setup.py sdist \
# Install the built Mayan EDMS package # Install the built Mayan EDMS package
&& pip install --no-cache-dir --no-use-pep517 dist/mayan* \ && pip install --no-cache-dir dist/mayan* \
# Install the static content # Install the static content
&& mayan-edms.py installdependencies \ && mayan-edms.py installdependencies \
&& MAYAN_STATIC_ROOT=${PROJECT_INSTALL_DIR}/static mayan-edms.py preparestatic --link --noinput && MAYAN_STATIC_ROOT=${PROJECT_INSTALL_DIR}/static mayan-edms.py preparestatic --link --noinput

View File

@@ -8,12 +8,12 @@ CONCURRENCY_ARGUMENT=--concurrency=
DEFAULT_USER_UID=1000 DEFAULT_USER_UID=1000
DEFAULT_USER_GUID=1000 DEFAULT_USER_GUID=1000
export MAYAN_DEFAULT_BROKER_URL=redis://127.0.0.1:6379/0 export MAYAN_DEFAULT_CELERY_BROKER_URL=redis://127.0.0.1:6379/0
export MAYAN_DEFAULT_CELERY_RESULT_BACKEND=redis://127.0.0.1:6379/0 export MAYAN_DEFAULT_CELERY_RESULT_BACKEND=redis://127.0.0.1:6379/0
export MAYAN_ALLOWED_HOSTS='["*"]' export MAYAN_ALLOWED_HOSTS='["*"]'
export MAYAN_BIN=/opt/mayan-edms/bin/mayan-edms.py export MAYAN_BIN=/opt/mayan-edms/bin/mayan-edms.py
export MAYAN_BROKER_URL=${MAYAN_BROKER_URL:-${MAYAN_DEFAULT_BROKER_URL}} export MAYAN_CELERY_BROKER_URL=${MAYAN_CELERY_BROKER_URL:-${MAYAN_DEFAULT_CELERY_BROKER_URL}}
export MAYAN_CELERY_RESULT_BACKEND=${MAYAN_CELERY_RESULT_BACKEND:-${MAYAN_DEFAULT_CELERY_RESULT_BACKEND}} export MAYAN_CELERY_RESULT_BACKEND=${MAYAN_CELERY_RESULT_BACKEND:-${MAYAN_DEFAULT_CELERY_RESULT_BACKEND}}
export MAYAN_INSTALL_DIR=/opt/mayan-edms export MAYAN_INSTALL_DIR=/opt/mayan-edms
export MAYAN_PYTHON_BIN_DIR=/opt/mayan-edms/bin/ export MAYAN_PYTHON_BIN_DIR=/opt/mayan-edms/bin/

View File

@@ -220,11 +220,11 @@ of a restart or power failure. The Gunicorn workers are increased to 3.
--------------------------------------------------------------------- ---------------------------------------------------------------------
Replace (paying attention to the comma at the end):: Replace (paying attention to the comma at the end)::
MAYAN_BROKER_URL="redis://127.0.0.1:6379/0", MAYAN_CELERY_BROKER_URL="redis://127.0.0.1:6379/0",
with:: with::
MAYAN_BROKER_URL="amqp://mayan:mayanrabbitmqpassword@localhost:5672/mayan", MAYAN_CELERY_BROKER_URL="amqp://mayan:mayanrabbitmqpassword@localhost:5672/mayan",
increase the number of Gunicorn workers to 3 in the line (``-w 2`` section):: increase the number of Gunicorn workers to 3 in the line (``-w 2`` section)::

View File

@@ -190,7 +190,7 @@ the default port. Not used with SQLite. For more information read the
pertinent Django documentation page: pertinent Django documentation page:
:django-docs:`Settings, PORT <ref/settings/#port>` :django-docs:`Settings, PORT <ref/settings/#port>`
``MAYAN_BROKER_URL`` ``MAYAN_CELERY_BROKER_URL``
This optional environment variable determines the broker that Celery will use This optional environment variable determines the broker that Celery will use
to relay task messages between the frontend code and the background workers. to relay task messages between the frontend code and the background workers.
@@ -200,7 +200,7 @@ For more information read the pertinent Celery Kombu documentation page: `Broker
This Docker image supports using Redis and RabbitMQ as brokers. This Docker image supports using Redis and RabbitMQ as brokers.
Caveat: If the `MAYAN_BROKER_URL` and `MAYAN_CELERY_RESULT_BACKEND` environment Caveat: If the `MAYAN_CELERY_BROKER_URL` and `MAYAN_CELERY_RESULT_BACKEND` environment
variables are specified, the built-in Redis server inside the container will variables are specified, the built-in Redis server inside the container will
be disabled. be disabled.
@@ -215,7 +215,7 @@ code. For more information read the pertinent Celery Kombu documentation page:
This Docker image supports using Redis and RabbitMQ as result backends. This Docker image supports using Redis and RabbitMQ as result backends.
Caveat: If the `MAYAN_BROKER_URL` and `MAYAN_CELERY_RESULT_BACKEND` environment Caveat: If the `MAYAN_CELERY_BROKER_URL` and `MAYAN_CELERY_RESULT_BACKEND` environment
variables are specified, the built-in Redis server inside the container will variables are specified, the built-in Redis server inside the container will
be disabled. be disabled.

View File

@@ -94,11 +94,11 @@ For the Docker image, launch a separate RabbitMQ container
docker run -d --name mayan-edms-rabbitmq -e RABBITMQ_DEFAULT_USER=mayan -e RABBITMQ_DEFAULT_PASS=mayanrabbitmqpassword -e RABBITMQ_DEFAULT_VHOST=mayan rabbitmq:3 docker run -d --name mayan-edms-rabbitmq -e RABBITMQ_DEFAULT_USER=mayan -e RABBITMQ_DEFAULT_PASS=mayanrabbitmqpassword -e RABBITMQ_DEFAULT_VHOST=mayan rabbitmq:3
Pass the MAYAN_BROKER_URL environment variable (https://kombu.readthedocs.io/en/latest/userguide/connections.html#connection-urls) Pass the MAYAN_CELERY_BROKER_URL environment variable (https://kombu.readthedocs.io/en/latest/userguide/connections.html#connection-urls)
to the Mayan EDMS container so that it uses the RabbitMQ container the to the Mayan EDMS container so that it uses the RabbitMQ container the
message broker:: message broker::
-e MAYAN_BROKER_URL="amqp://mayan:mayanrabbitmqpassword@localhost:5672/mayan", -e MAYAN_CELERY_BROKER_URL="amqp://mayan:mayanrabbitmqpassword@localhost:5672/mayan",
When tasks finish, they leave behind a return status or the result of a When tasks finish, they leave behind a return status or the result of a
calculation, these are stored for a while so that whoever requested the calculation, these are stored for a while so that whoever requested the

View File

@@ -52,7 +52,9 @@ Changes
- Backport file cache manager app. - Backport file cache manager app.
- Convert document image cache to use file cache manager app. - Convert document image cache to use file cache manager app.
Add setting DOCUMENTS_CACHE_MAXIMUM_SIZE defaults to 500 MB. Add setting DOCUMENTS_CACHE_MAXIMUM_SIZE defaults to 500 MB.
- Update Celery to version 4.3.0. Settings changed:
MAYAN_BROKER_URL to MAYAN_CELERY_BROKER_URL,
MAYAN_CELERY_ALWAYS_EAGER to MAYAN_CELERY_TASK_ALWAYS_EAGER.
Removals Removals
-------- --------

View File

@@ -117,31 +117,39 @@ PythonDependency(
Celery under the GPL license. The BSD license, unlike the GPL, Celery under the GPL license. The BSD license, unlike the GPL,
let you distribute a modified version without making your let you distribute a modified version without making your
changes open source. changes open source.
''', module=__name__, name='celery', version_string='==3.1.24' ''', module=__name__, name='celery', version_string='==4.3.0'
) )
PythonDependency( PythonDependency(
copyright_text=''' copyright_text='''
Copyright (c) 2012-2013 GoPivotal, Inc. All Rights Reserved. Copyright (c) 2015-2016 Ask Solem. All Rights Reserved.
Copyright (c) 2012-2014 GoPivotal, Inc. All Rights Reserved.
Copyright (c) 2009-2012 Ask Solem. All Rights Reserved. Copyright (c) 2009-2012 Ask Solem. All Rights Reserved.
All rights reserved.
django-celery-beat is licensed under The BSD License (3 Clause, also known as
the new BSD license). The license is an OSI approved Open Source
license and is GPL-compatible(1).
The license text can also be found here:
http://www.opensource.org/licenses/BSD-3-Clause
License
=======
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright notice, notice, this list of conditions and the following disclaimer.
this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
documentation and/or other materials provided with the distribution. * Neither the name of Ask Solem nor the
names of its contributors may be used to endorse or promote products
Neither the name of Ask Solem nor the names of its contributors may be used derived from this software without specific prior written permission.
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Ask Solem OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -149,7 +157,25 @@ PythonDependency(
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
''', module=__name__, name='django-celery', version_string='==3.2.1'
Documentation License
=====================
The documentation portion of django-celery-beat (the rendered contents of the
"docs" directory of a software distribution or checkout) is supplied
under the "Creative Commons Attribution-ShareAlike 4.0
International" (CC BY-SA 4.0) License as described by
http://creativecommons.org/licenses/by-sa/4.0/
Footnotes
=========
(1) A GPL-compatible license makes it possible to
combine django-celery-beat with other software that is released
under the GPL, it does not mean that we're distributing
django-celery-beat under the GPL license. The BSD license, unlike the GPL,
let you distribute a modified version without making your
changes open source.
''', module=__name__, name='django-celery-beat', version_string='==1.5.0'
) )
PythonDependency( PythonDependency(
module=__name__, name='django-downloadview', version_string='==1.9' module=__name__, name='django-downloadview', version_string='==1.9'

View File

@@ -107,7 +107,7 @@ class Statistic(object):
day_of_month=day_of_month, month_of_year=month_of_year, day_of_month=day_of_month, month_of_year=month_of_year,
) )
app.conf.CELERYBEAT_SCHEDULE.update( app.conf.beat_schedule.update(
{ {
self.get_task_name(): { self.get_task_name(): {
'task': task_execute_statistic.dotted_path, 'task': task_execute_statistic.dotted_path,
@@ -117,7 +117,7 @@ class Statistic(object):
} }
) )
app.conf.CELERY_ROUTES.update( app.conf.task_routes.update(
{ {
self.get_task_name(): { self.get_task_name(): {
'queue': queue_statistics.name 'queue': queue_statistics.name

View File

@@ -140,9 +140,9 @@ class PlatformTemplateSupervisord(PlatformTemplate):
environment_name='MAYAN_ALLOWED_HOSTS' environment_name='MAYAN_ALLOWED_HOSTS'
), ),
YAMLVariable( YAMLVariable(
name='BROKER_URL', name='CELERY_BROKER_URL',
default='redis://127.0.0.1:6379/0', default='redis://127.0.0.1:6379/0',
environment_name='MAYAN_BROKER_URL' environment_name='MAYAN_CELERY_BROKER_URL'
), ),
YAMLVariable( YAMLVariable(
name='CELERY_RESULT_BACKEND', name='CELERY_RESULT_BACKEND',

View File

@@ -1,11 +1,11 @@
[supervisord] [supervisord]
environment= environment=
PYTHONPATH={{ INSTALLATION_PATH }}/lib/python2.7/site-packages:{{ MEDIA_ROOT }}/mayan_settings, PYTHONPATH={{ INSTALLATION_PATH }}/lib/python3.7/site-packages:{{ MEDIA_ROOT }}/mayan_settings,
DJANGO_SETTINGS_MODULE=mayan.settings.production, DJANGO_SETTINGS_MODULE=mayan.settings.production,
MAYAN_MEDIA_ROOT="{{ MEDIA_ROOT }}", MAYAN_MEDIA_ROOT="{{ MEDIA_ROOT }}",
MAYAN_ALLOWED_HOSTS="{{ ALLOWED_HOSTS }}", MAYAN_ALLOWED_HOSTS="{{ ALLOWED_HOSTS }}",
MAYAN_CELERY_RESULT_BACKEND="{{ CELERY_RESULT_BACKEND }}", MAYAN_CELERY_RESULT_BACKEND="{{ CELERY_RESULT_BACKEND }}",
MAYAN_BROKER_URL="{{ BROKER_URL }}", MAYAN_CELERY_BROKER_URL="{{ CELERY_BROKER_URL }}",
MAYAN_DATABASES="{{ DATABASES }}" MAYAN_DATABASES="{{ DATABASES }}"
[program:mayan-gunicorn] [program:mayan-gunicorn]
@@ -18,7 +18,7 @@ user = mayan
[program:mayan-worker-{{ worker.name }}] [program:mayan-worker-{{ worker.name }}]
autorestart = true autorestart = true
autostart = true autostart = true
command = nice -n {{ worker.nice_level }} {{ INSTALLATION_PATH }}/bin/mayan-edms.py celery worker -Ofair -l ERROR -Q {% for queue in worker.queues %}{{ queue.name }}{% if not forloop.last %},{% endif %}{% endfor %} -n mayan-worker-{{ worker.name }}.%%h --concurrency=1 command = nice -n {{ worker.nice_level }} {{ INSTALLATION_PATH }}/bin/celery worker -A mayan -Ofair -l ERROR -Q {% for queue in worker.queues %}{{ queue.name }}{% if not forloop.last %},{% endif %}{% endfor %} -n mayan-worker-{{ worker.name }}.%%h --concurrency=1
killasgroup = true killasgroup = true
numprocs = 1 numprocs = 1
priority = 998 priority = 998
@@ -30,7 +30,7 @@ user = mayan
[program:mayan-celery-beat] [program:mayan-celery-beat]
autorestart = true autorestart = true
autostart = true autostart = true
command = nice -n 1 {{ INSTALLATION_PATH }}/bin/mayan-edms.py celery beat --pidfile= -l ERROR command = nice -n 1 {{ INSTALLATION_PATH }}/bin/celery beat -A mayan --pidfile= -l ERROR
killasgroup = true killasgroup = true
numprocs = 1 numprocs = 1
priority = 998 priority = 998

View File

@@ -1,3 +1,7 @@
[supervisord]
environment=
DJANGO_SETTINGS_MODULE="%(ENV_MAYAN_SETTINGS_MODULE)s"
[program:mayan-gunicorn] [program:mayan-gunicorn]
autorestart = false autorestart = false
autostart = true autostart = true
@@ -12,7 +16,7 @@ user = mayan
[program:redis] [program:redis]
autorestart = false autorestart = false
autostart = true autostart = true
command = /bin/bash -c "if [ ${MAYAN_BROKER_URL} == ${MAYAN_DEFAULT_BROKER_URL} ] && [ ${MAYAN_CELERY_RESULT_BACKEND} == ${MAYAN_DEFAULT_CELERY_RESULT_BACKEND} ];then /usr/bin/redis-server /etc/redis/;fi" command = /bin/bash -c "if [ ${MAYAN_CELERY_BROKER_URL} == ${MAYAN_DEFAULT_CELERY_BROKER_URL} ] && [ ${MAYAN_CELERY_RESULT_BACKEND} == ${MAYAN_DEFAULT_CELERY_RESULT_BACKEND} ];then /usr/bin/redis-server /etc/redis/;fi"
stderr_logfile = /dev/fd/2 stderr_logfile = /dev/fd/2
stderr_logfile_maxbytes = 0 stderr_logfile_maxbytes = 0
stdout_logfile = /dev/fd/1 stdout_logfile = /dev/fd/1
@@ -23,7 +27,7 @@ user = root
[program:mayan-worker-{{ worker.name }}] [program:mayan-worker-{{ worker.name }}]
autorestart = false autorestart = false
autostart = true autostart = true
command = nice -n {{ worker.nice_level }} /bin/bash -c "${MAYAN_BIN} celery --settings=${MAYAN_SETTINGS_MODULE} worker -Ofair -l ERROR -Q {% for queue in worker.queues %}{{ queue.name }}{% if not forloop.last %},{% endif %}{% endfor %} -n mayan-worker-{{ worker.name }}.%%h ${MAYAN_WORKER_{{ worker.name|upper }}_CONCURRENCY}" command = nice -n {{ worker.nice_level }} /bin/bash -c "${MAYAN_PYTHON_BIN_DIR}celery worker -A mayan -Ofair -l ERROR -Q {% for queue in worker.queues %}{{ queue.name }}{% if not forloop.last %},{% endif %}{% endfor %} -n mayan-worker-{{ worker.name }}.%%h ${MAYAN_WORKER_{{ worker.name|upper }}_CONCURRENCY}"
killasgroup = true killasgroup = true
numprocs = 1 numprocs = 1
priority = 998 priority = 998
@@ -39,7 +43,7 @@ user = mayan
[program:mayan-celery-beat] [program:mayan-celery-beat]
autorestart = false autorestart = false
autostart = true autostart = true
command = nice -n 1 /bin/bash -c "${MAYAN_BIN} celery --settings=${MAYAN_SETTINGS_MODULE} beat --pidfile= -l ERROR" command = nice -n 1 /bin/bash -c "${MAYAN_PYTHON_BIN_DIR}celery -A mayan beat --pidfile= -l ERROR"
killasgroup = true killasgroup = true
numprocs = 1 numprocs = 1
priority = 998 priority = 998

View File

@@ -34,7 +34,11 @@ def get_environment_variables():
def get_environment_setting(name, fallback_default=None): def get_environment_setting(name, fallback_default=None):
value = os.environ.get('MAYAN_{}'.format(name), get_default(name=name, fallback_default=fallback_default)) value = os.environ.get(
'MAYAN_{}'.format(name), get_default(
name=name, fallback_default=fallback_default
)
)
if value: if value:
return yaml.load(stream=value, Loader=SafeLoader) return yaml.load(stream=value, Loader=SafeLoader)

View File

@@ -7,7 +7,7 @@ from django.db import models, transaction
from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from djcelery.models import PeriodicTask, IntervalSchedule from django_celery_beat.models import PeriodicTask, IntervalSchedule
from model_utils.managers import InheritanceManager from model_utils.managers import InheritanceManager
from mayan.apps.common.compressed_files import Archive from mayan.apps.common.compressed_files import Archive

View File

@@ -156,13 +156,13 @@ class CeleryQueue(object):
if self.transient: if self.transient:
kwargs['delivery_mode'] = 1 kwargs['delivery_mode'] = 1
celery_app.conf.CELERY_QUEUES.append(Queue(**kwargs)) celery_app.conf.task_queues.append(Queue(**kwargs))
if self.default_queue: if self.default_queue:
celery_app.conf.CELERY_DEFAULT_QUEUE = self.name celery_app.conf.task_default_queue = self.name
for task_type in self.task_types: for task_type in self.task_types:
celery_app.conf.CELERY_ROUTES.update( celery_app.conf.task_routes.update(
{ {
task_type.dotted_path: { task_type.dotted_path: {
'queue': self.name 'queue': self.name
@@ -171,7 +171,7 @@ class CeleryQueue(object):
) )
if task_type.schedule: if task_type.schedule:
celery_app.conf.CELERYBEAT_SCHEDULE.update( celery_app.conf.beat_schedule.update(
{ {
task_type.name: { task_type.name: {
'task': task_type.dotted_path, 'task': task_type.dotted_path,

View File

@@ -10,7 +10,7 @@ __all__ = ()
namespace = Namespace(label=_('Celery'), name='celery') namespace = Namespace(label=_('Celery'), name='celery')
setting_celery_broker_url = namespace.add_setting( setting_celery_broker_url = namespace.add_setting(
global_name='BROKER_URL', default=None, global_name='CELERY_BROKER_URL', default=None,
help_text=_( help_text=_(
'Default: "amqp://". Default broker URL. This must be a URL in ' 'Default: "amqp://". Default broker URL. This must be a URL in '
'the form of: transport://userid:password@hostname:port/virtual_host ' 'the form of: transport://userid:password@hostname:port/virtual_host '

View File

@@ -9,6 +9,5 @@ from .runtime import celery_class
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mayan.settings.production') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mayan.settings.production')
app = celery_class('mayan') app = celery_class('mayan')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

View File

@@ -74,7 +74,7 @@ INSTALLED_APPS = (
'actstream', 'actstream',
'colorful', 'colorful',
'corsheaders', 'corsheaders',
'djcelery', 'django_celery_beat',
'formtools', 'formtools',
'mathfilters', 'mathfilters',
'mptt', 'mptt',
@@ -280,18 +280,25 @@ PAGINATION_SETTINGS = {
# ----------- Celery ---------- # ----------- Celery ----------
CELERY_BROKER_URL = get_environment_setting(name='CELERY_BROKER_URL')
CELERY_RESULT_BACKEND = get_environment_setting(name='CELERY_RESULT_BACKEND')
CELERY_TASK_ALWAYS_EAGER = get_environment_setting(
name='CELERY_TASK_ALWAYS_EAGER'
)
CELERY_ACCEPT_CONTENT = ('json',) CELERY_ACCEPT_CONTENT = ('json',)
CELERY_ALWAYS_EAGER = False CELERY_BEAT_SCHEDULE = {}
CELERY_CREATE_MISSING_QUEUES = False CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers.DatabaseScheduler'
CELERY_DISABLE_RATE_LIMITS = True CELERY_DISABLE_RATE_LIMITS = True
CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
CELERY_ENABLE_UTC = True CELERY_ENABLE_UTC = True
CELERY_QUEUES = []
CELERY_RESULT_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json'
CELERY_ROUTES = {} CELERY_TASK_ALWAYS_EAGER = False
CELERY_TASK_CREATE_MISSING_QUEUES = False
CELERY_TASK_EAGER_PROPAGATES = True
CELERY_TASK_QUEUES = []
CELERY_TASK_ROUTES = {}
CELERY_TASK_SERIALIZER = 'json' CELERY_TASK_SERIALIZER = 'json'
CELERY_TIMEZONE = 'UTC' CELERY_TIMEZONE = 'UTC'
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
# ------------ CORS ------------ # ------------ CORS ------------
@@ -318,12 +325,6 @@ SWAGGER_SETTINGS = {
AJAX_REDIRECT_CODE = 278 AJAX_REDIRECT_CODE = 278
# ----- Celery -----
BROKER_URL = get_environment_setting(name='BROKER_URL')
CELERY_ALWAYS_EAGER = get_environment_setting(name='CELERY_ALWAYS_EAGER')
CELERY_RESULT_BACKEND = get_environment_setting(name='CELERY_RESULT_BACKEND')
# ----- Database ----- # ----- Database -----
DATABASES = { DATABASES = {
'default': { 'default': {

View File

@@ -1,17 +1,20 @@
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
from mayan.apps.smart_settings.utils import get_environment_setting
from . import * # NOQA from . import * # NOQA
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['*']
DEBUG = True DEBUG = True
CELERY_ALWAYS_EAGER = True CELERY_TASK_ALWAYS_EAGER = get_environment_setting(
CELERY_EAGER_PROPAGATES_EXCEPTIONS = CELERY_ALWAYS_EAGER name='CELERY_TASK_ALWAYS_EAGER', fallback_default='true'
)
CELERY_TASK_EAGER_PROPAGATES = CELERY_TASK_ALWAYS_EAGER
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
if 'rosetta' not in INSTALLED_APPS: if 'rosetta' not in INSTALLED_APPS:
try: try:
import rosetta import rosetta

View File

@@ -2,7 +2,7 @@ from __future__ import absolute_import, unicode_literals
from . import * # NOQA from . import * # NOQA
CELERY_ALWAYS_EAGER = False CELERY_TASK_ALWAYS_EAGER = False
TEMPLATES[0]['OPTIONS']['loaders'] = ( TEMPLATES[0]['OPTIONS']['loaders'] = (
( (

View File

@@ -12,6 +12,6 @@ DATABASES = {
} }
} }
BROKER_URL = 'redis://127.0.0.1:6379/0' CELERY_BROKER_URL = 'redis://127.0.0.1:6379/0'
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/0' CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/0'
DEBUG = True DEBUG = True

View File

@@ -2,8 +2,8 @@ from __future__ import absolute_import, unicode_literals
from .. import * # NOQA from .. import * # NOQA
CELERY_ALWAYS_EAGER = True CELERY_TASK_ALWAYS_EAGER = True
CELERY_EAGER_PROPAGATES_EXCEPTIONS = True CELERY_TASK_EAGER_PROPAGATES = True
BROKER_BACKEND = 'memory' BROKER_BACKEND = 'memory'
COMMON_PRODUCTION_ERROR_LOG_PATH = '/tmp/mayan-errors.log' COMMON_PRODUCTION_ERROR_LOG_PATH = '/tmp/mayan-errors.log'

View File

@@ -1,6 +1,7 @@
# Packages to be remove during upgrades # Packages to be remove during upgrades
cssmin cssmin
django-autoadmin django-autoadmin
django-celery
django-environ django-environ
django-suit django-suit
django-compressor django-compressor