summaryrefslogtreecommitdiffstats
path: root/ocata
diff options
context:
space:
mode:
Diffstat (limited to 'ocata')
-rw-r--r--ocata/docker/Dockerfile2
-rw-r--r--ocata/ocata/__init__.py7
-rw-r--r--ocata/ocata/celery.py38
-rw-r--r--ocata/requirements.txt4
-rwxr-xr-xocata/run.sh5
5 files changed, 55 insertions, 1 deletions
diff --git a/ocata/docker/Dockerfile b/ocata/docker/Dockerfile
index cca1cf89..97bbc7ba 100644
--- a/ocata/docker/Dockerfile
+++ b/ocata/docker/Dockerfile
@@ -18,7 +18,7 @@ ENV AAI_PASSWORD "AAI"
EXPOSE 9006
WORKDIR /opt/ocata
-RUN apt-get update && apt-get install -y memcached unzip
+RUN apt-get update && apt-get install -y memcached unzip rabbitmq-server
RUN wget -O /opt/multicloud-openstack-ocata.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.multicloud.openstack&a=multicloud-openstack-ocata&e=zip&v=LATEST" && \
unzip -q -o -B /opt/multicloud-openstack-ocata.zip -d /opt/ && \
rm -f /opt/multicloud-openstack-ocata.zip
diff --git a/ocata/ocata/__init__.py b/ocata/ocata/__init__.py
index afa702d3..f7fd66a2 100644
--- a/ocata/ocata/__init__.py
+++ b/ocata/ocata/__init__.py
@@ -12,3 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+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']
diff --git a/ocata/ocata/celery.py b/ocata/ocata/celery.py
new file mode 100644
index 00000000..ee533b5d
--- /dev/null
+++ b/ocata/ocata/celery.py
@@ -0,0 +1,38 @@
+# Copyright (c) 2017-2018 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from __future__ import absolute_import, unicode_literals
+import os
+from celery import Celery
+import logging
+
+# set the default Django settings module for the 'celery' program.
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ocata.settings')
+
+app = Celery('ocata')
+
+# 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()
+
+logger = logging.getLogger(__name__)
+
+@app.task(bind=True)
+def debug_task(self):
+ logger.debug("self.request")
diff --git a/ocata/requirements.txt b/ocata/requirements.txt
index 5408c53b..260e1bad 100644
--- a/ocata/requirements.txt
+++ b/ocata/requirements.txt
@@ -21,3 +21,7 @@ unittest_xml_reporting==1.12.0
# for onap logging
onappylog>=1.0.6
+
+# for background tasks
+celery >= 4.0
+
diff --git a/ocata/run.sh b/ocata/run.sh
index 70af4df9..541eaf10 100755
--- a/ocata/run.sh
+++ b/ocata/run.sh
@@ -15,4 +15,9 @@
memcached -d -m 2048 -u root -c 1024 -p 11211 -P /tmp/memcached1.pid
export PYTHONPATH=lib/share
+
+service rabbitmq-server restart
+# make sure only 1 worker due to missing the synchronization between workers now
+nohup celery -A ocata worker --concurrency=1 --loglevel=debug &
+
uwsgi --http :9006 --module ocata.wsgi --master --processes 4