changeset 777:aac24db58ce8 beta

fixed cache problem, updated docs
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 27 Nov 2010 01:43:04 +0100
parents f6c613fba757
children c3fab5b06af3
files docs/changelog.rst docs/setup.rst rhodecode/lib/celerylib/tasks.py rhodecode/lib/indexers/daemon.py
diffstat 4 files changed, 46 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/docs/changelog.rst	Sat Nov 27 01:27:24 2010 +0100
+++ b/docs/changelog.rst	Sat Nov 27 01:43:04 2010 +0100
@@ -24,7 +24,7 @@
   and options to disable those hooks from admin panel
 - introduced new enhanced changelog for merges that shows more accurate results
 - gui optimizations, fixed application width to 1024px
-- whoosh,celeryd,upgrade moved to paster command
+- whoosh, celeryd, upgrade moved to paster command
 
 fixes
 +++++
--- a/docs/setup.rst	Sat Nov 27 01:27:24 2010 +0100
+++ b/docs/setup.rst	Sat Nov 27 01:43:04 2010 +0100
@@ -131,6 +131,22 @@
 ldap will be saved there.
 
 
+
+Setting Up Celery
+-----------------
+
+Since version 1.1 celery is configured by the rhodecode ini configuration files
+simply set use_celery=true in the ini file then add / change the configuration 
+variables inside the ini file.
+
+Remember that the ini files uses format with '.' not with '_' like celery
+so for example setting `BROKER_HOST` in celery means setting `broker.host` in
+the config file.
+
+In order to make start using celery run::
+ paster celeryd <configfile.ini>
+
+
 Nginx virtual host example
 --------------------------
 
--- a/rhodecode/lib/celerylib/tasks.py	Sat Nov 27 01:27:24 2010 +0100
+++ b/rhodecode/lib/celerylib/tasks.py	Sat Nov 27 01:43:04 2010 +0100
@@ -21,6 +21,31 @@
 
 from sqlalchemy import engine_from_config
 
+#set cache regions for beaker so celery can utilise it
+def add_cache(settings):
+    cache_settings = {'regions':None}
+    for key in settings.keys():
+        for prefix in ['beaker.cache.', 'cache.']:
+            if key.startswith(prefix):
+                name = key.split(prefix)[1].strip()
+                cache_settings[name] = settings[key].strip()
+    if cache_settings['regions']:
+        for region in cache_settings['regions'].split(','):
+            region = region.strip()
+            region_settings = {}
+            for key, value in cache_settings.items():
+                if key.startswith(region):
+                    region_settings[key.split('.')[1]] = value
+            region_settings['expire'] = int(region_settings.get('expire',
+                                                                60))
+            region_settings.setdefault('lock_dir',
+                                       cache_settings.get('lock_dir'))
+            if 'type' not in region_settings:
+                region_settings['type'] = cache_settings.get('type',
+                                                             'memory')
+            beaker.cache.cache_regions[region] = region_settings
+add_cache(config)
+
 try:
     import json
 except ImportError:
@@ -51,7 +76,8 @@
     from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
     index_location = config['index_dir']
     WhooshIndexingDaemon(index_location=index_location,
-                         repo_location=repo_location).run(full_index=full_index)
+                         repo_location=repo_location, sa=get_session())\
+                         .run(full_index=full_index)
 
 @task
 @locked_task
--- a/rhodecode/lib/indexers/daemon.py	Sat Nov 27 01:27:24 2010 +0100
+++ b/rhodecode/lib/indexers/daemon.py	Sat Nov 27 01:43:04 2010 +0100
@@ -67,7 +67,7 @@
     """
 
     def __init__(self, indexname='HG_INDEX', index_location=None,
-                 repo_location=None):
+                 repo_location=None, sa=None):
         self.indexname = indexname
 
         self.index_location = index_location
@@ -78,7 +78,7 @@
         if not repo_location:
             raise Exception('You have to provide repositories location')
 
-        self.repo_paths = ScmModel().repo_scan(self.repo_location, None)
+        self.repo_paths = ScmModel(sa).repo_scan(self.repo_location, None)
         self.initial = False
         if not os.path.isdir(self.index_location):
             os.makedirs(self.index_location)