Commit e5c34594 by Őry Máté

Merge branch 'issue-119' into 'master'

Change Celery result backend to memcached #119

Moving result backend to memchached.

🆗 Celery configurations
🆗 Docs
🚧 Testing

Install:

* `sudo apt-get install memcached libmemcached-dev`
* `pip install -r requirements/base.txt`  (`pip install pylibmc`)
*   update ALL virtualenvs and their config: `export CACHE_URI='pylibmc://127.0.0.1:11211/'`
parents 9fa233a4 da1aa249
...@@ -322,7 +322,7 @@ VM_SCHEDULER = 'manager.scheduler' ...@@ -322,7 +322,7 @@ VM_SCHEDULER = 'manager.scheduler'
CACHES = { CACHES = {
'default': { 'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'BACKEND': 'pylibmc',
'LOCATION': '127.0.0.1:11211', 'LOCATION': '127.0.0.1:11211',
} }
} }
......
...@@ -38,7 +38,8 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' ...@@ -38,7 +38,8 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
CACHES = { CACHES = {
'default': { 'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
} }
} }
########## END CACHE CONFIGURATION ########## END CACHE CONFIGURATION
......
...@@ -4,8 +4,9 @@ from kombu import Queue, Exchange ...@@ -4,8 +4,9 @@ from kombu import Queue, Exchange
from os import getenv from os import getenv
HOSTNAME = "localhost" HOSTNAME = "localhost"
CACHE_URI = getenv("CACHE_URI", "pylibmc://127.0.0.1:11211/")
celery = Celery('manager', backend='amqp', celery = Celery('manager',
broker=getenv("AMQP_URI"), broker=getenv("AMQP_URI"),
include=['vm.tasks.local_tasks', include=['vm.tasks.local_tasks',
'vm.tasks.local_periodic_tasks', 'vm.tasks.local_periodic_tasks',
...@@ -15,6 +16,8 @@ celery = Celery('manager', backend='amqp', ...@@ -15,6 +16,8 @@ celery = Celery('manager', backend='amqp',
'firewall.tasks.local_tasks', ]) 'firewall.tasks.local_tasks', ])
celery.conf.update( celery.conf.update(
CELERY_RESULT_BACKEND='cache',
CELERY_CACHE_BACKEND=CACHE_URI,
CELERY_TASK_RESULT_EXPIRES=300, CELERY_TASK_RESULT_EXPIRES=300,
CELERY_QUEUES=( CELERY_QUEUES=(
Queue(HOSTNAME + '.man', Exchange('manager', type='direct'), Queue(HOSTNAME + '.man', Exchange('manager', type='direct'),
......
...@@ -51,7 +51,8 @@ Update the package lists, and install the required system software:: ...@@ -51,7 +51,8 @@ Update the package lists, and install the required system software::
$ sudo apt-get update $ sudo apt-get update
$ sudo apt-get install --yes virtualenvwrapper postgresql git \ $ sudo apt-get install --yes virtualenvwrapper postgresql git \
python-pip rabbitmq-server libpq-dev python-dev ntp python-pip rabbitmq-server libpq-dev python-dev ntp memcached \
libmemcached-dev
Set up *PostgreSQL* to listen on localhost and restart it:: Set up *PostgreSQL* to listen on localhost and restart it::
...@@ -117,6 +118,7 @@ Set up default Circle configuration and activate the virtual environment:: ...@@ -117,6 +118,7 @@ Set up default Circle configuration and activate the virtual environment::
"localhost", "dns_ttl": "300", "reload_sleep": "10", "localhost", "dns_ttl": "300", "reload_sleep": "10",
"rdns_ip": "152.66.243.60", "default_vlangroup": "publikus"}' "rdns_ip": "152.66.243.60", "default_vlangroup": "publikus"}'
export AMQP_URI='amqp://cloud:password@localhost:5672/circle' export AMQP_URI='amqp://cloud:password@localhost:5672/circle'
export CACHE_URI='pylibmc://127.0.0.1:11211/'
END END
$ workon circle $ workon circle
$ cd ~/circle $ cd ~/circle
......
...@@ -13,3 +13,4 @@ netaddr==0.7.10 ...@@ -13,3 +13,4 @@ netaddr==0.7.10
requests==2.2.1 requests==2.2.1
South==0.8.1 South==0.8.1
psycopg2==2.5.1 psycopg2==2.5.1
pylibmc
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment