@@ -45,51 +45,60 @@ You are ready to use rhodecode, to run i
127.0.0.1:5000. This ip and port is configurable via the production.ini
file created in previous step
- Use admin account you created to login.
- Default permissions on each repository is read, and owner is admin. So
remember to update these if needed. In the admin panel You can toggle ldap,
anonymous, permissions settings. As well as edit more advanced options on
users and repositories
Setting up Whoosh full text search
----------------------------------
Index for whoosh can be build starting from version 1.1 using paster command
passing repo locations to index, as well as Your config file that stores
whoosh index files locations. There is possible to pass `-f` to the options
Starting from version 1.1 whoosh index can be build using paster command.
You have to specify the config file that stores location of index, and
location of repositories (`--repo-location`). Starting from version 1.2 it is
also possible to specify a comma separated list of repositories (`--index-only`)
to build index only on chooses repositories skipping any other found in repos
location
There is possible also to pass `-f` to the options
to enable full index rebuild. Without that indexing will run always in in
incremental mode.
::
incremental mode::
paster make-index production.ini --repo-location=<location for repos>
for full index rebuild You can use
for full index rebuild You can use::
paster make-index production.ini -f --repo-location=<location for repos>
- For full text search You can either put crontab entry for
building index just for chosen repositories is possible with such command::
paster make-index production.ini --repo-location=<location for repos> --index-only=vcs,rhodecode
This command can be run even from crontab in order to do periodical
index builds and keep Your index always up to date. An example entry might
look like this
In order to do periodical index builds and keep Your index always up to date.
It's recommended to do a crontab entry for incremental indexing.
An example entry might look like this
/path/to/python/bin/paster /path/to/rhodecode/production.ini --repo-location=<location for repos>
When using incremental(default) mode whoosh will check last modification date
When using incremental (default) mode whoosh will check last modification date
of each file and add it to reindex if newer file is available. Also indexing
daemon checks for removed files and removes them from index.
Sometime You might want to rebuild index from scratch. You can do that using
the `-f` flag passed to paster command or, in admin panel You can check
`build from scratch` flag.
Setting up LDAP support
-----------------------
RhodeCode starting from version 1.1 supports ldap authentication. In order
import os
import sys
import traceback
from os.path import dirname as dn, join as jn
#to get the rhodecode import
sys.path.append(dn(dn(dn(os.path.realpath(__file__)))))
from string import strip
from rhodecode.model import init_model
from rhodecode.model.scm import ScmModel
from rhodecode.config.environment import load_environment
from rhodecode.lib.utils import BasePasterCommand, Command, add_cache
from shutil import rmtree
from webhelpers.html.builder import escape
from vcs.utils.lazy import LazyProperty
from sqlalchemy import engine_from_config
from whoosh.analysis import RegexTokenizer, LowercaseFilter, StopFilter
@@ -62,45 +64,53 @@ class MakeIndex(BasePasterCommand):
takes_config_file = -1
parser = Command.standard_parser(verbose=True)
def command(self):
from pylons import config
add_cache(config)
engine = engine_from_config(config, 'sqlalchemy.db1.')
init_model(engine)
index_location = config['index_dir']
repo_location = self.options.repo_location
repo_list = map(strip, self.options.repo_list.split(','))
#======================================================================
# WHOOSH DAEMON
from rhodecode.lib.pidlock import LockHeld, DaemonLock
from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
try:
l = DaemonLock()
WhooshIndexingDaemon(index_location=index_location,
repo_location=repo_location)\
repo_location=repo_location,
repo_list=repo_list)\
.run(full_index=self.options.full_index)
l.release()
except LockHeld:
sys.exit(1)
def update_parser(self):
self.parser.add_option('--repo-location',
action='store',
dest='repo_location',
help="Specifies repositories location to index REQUIRED",
)
self.parser.add_option('--index-only',
dest='repo_list',
help="Specifies a comma separated list of repositores "
"to build index on OPTIONAL",
self.parser.add_option('-f',
action='store_true',
dest='full_index',
help="Specifies that index should be made full i.e"
" destroy old and build from scratch",
default=False)
class ResultWrapper(object):
def __init__(self, search_type, searcher, matcher, highlight_items):
self.search_type = search_type
self.searcher = searcher
self.matcher = matcher
@@ -61,36 +61,46 @@ formatter = logging.Formatter("%(asctime
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
log.addHandler(ch)
class WhooshIndexingDaemon(object):
"""
Deamon for atomic jobs
def __init__(self, indexname='HG_INDEX', index_location=None,
repo_location=None, sa=None):
repo_location=None, sa=None, repo_list=None):
self.indexname = indexname
self.index_location = index_location
if not index_location:
raise Exception('You have to provide index location')
self.repo_location = repo_location
if not repo_location:
raise Exception('You have to provide repositories location')
self.repo_paths = ScmModel(sa).repo_scan(self.repo_location, None)
if repo_list:
filtered_repo_paths = {}
for repo_name, repo in self.repo_paths.items():
if repo_name in repo_list:
filtered_repo_paths[repo.name] = repo
self.repo_paths = filtered_repo_paths
self.initial = False
if not os.path.isdir(self.index_location):
os.makedirs(self.index_location)
log.info('Cannot run incremental index since it does not'
' yet exist running full build')
self.initial = True
def get_paths(self, repo):
"""recursive walk in root dir and return a set of all path in that dir
based on repository walk function
index_paths_ = set()
@@ -145,26 +155,26 @@ class WhooshIndexingDaemon(object):
def build_index(self):
if os.path.exists(self.index_location):
log.debug('removing previous index')
rmtree(self.index_location)
if not os.path.exists(self.index_location):
os.mkdir(self.index_location)
idx = create_in(self.index_location, SCHEMA, indexname=IDX_NAME)
writer = idx.writer()
print self.repo_paths.values()
for cnt, repo in enumerate(self.repo_paths.values()):
for repo in self.repo_paths.values():
log.debug('building index @ %s' % repo.path)
for idx_path in self.get_paths(repo):
self.add_doc(writer, idx_path, repo)
log.debug('>> COMMITING CHANGES <<')
writer.commit(merge=True)
log.debug('>>> FINISHED BUILDING INDEX <<<')
def update_index(self):
log.debug('STARTING INCREMENTAL INDEXING UPDATE')
Status change: