##// END OF EJS Templates
Implemented whoosh index building as paster command....
marcink -
r683:341beaa9 beta
parent child Browse files
Show More
@@ -7,7 +7,7 b' recursive-include rhodecode/i18n/ *'
7 recursive-include rhodecode/public/css *
7 recursive-include rhodecode/public/css *
8 recursive-include rhodecode/public/images *
8 recursive-include rhodecode/public/images *
9 #js
9 #js
10 include rhodecode/public/js/yui2.js
10 include rhodecode/public/js/yui2a.js
11 include rhodecode/public/js/excanvas.min.js
11 include rhodecode/public/js/excanvas.min.js
12 include rhodecode/public/js/yui.flot.js
12 include rhodecode/public/js/yui.flot.js
13 include rhodecode/public/js/graph.js
13 include rhodecode/public/js/graph.js
@@ -43,6 +43,7 b' full_stack = true'
43 static_files = true
43 static_files = true
44 lang=en
44 lang=en
45 cache_dir = %(here)s/data
45 cache_dir = %(here)s/data
46 index_dir = %(here)s/data/index
46
47
47 ####################################
48 ####################################
48 ### BEAKER CACHE ####
49 ### BEAKER CACHE ####
@@ -17,6 +17,7 b' 1.1.0 (**2010-XX-XX**)'
17 - introduced new enhanced changelog for merges that shows more accurate results
17 - introduced new enhanced changelog for merges that shows more accurate results
18 - gui optimizations, fixed application width to 1024px
18 - gui optimizations, fixed application width to 1024px
19 - numerous small bugfixes
19 - numerous small bugfixes
20 - whoosh index moved to paster command
20
21
21 1.0.2 (**2010-11-12**)
22 1.0.2 (**2010-11-12**)
22 ----------------------
23 ----------------------
@@ -41,21 +41,40 b' Setting up the application'
41 remember to update these if needed.
41 remember to update these if needed.
42
42
43
43
44 Setting up Whoosh
44 Setting up Whoosh full text search
45 -----------------
45 ----------------------------------
46
47 Index for whoosh can be build starting from version 1.1 using paster command
48 passing repo locations to index, as well as Your config file that stores
49 whoosh index files locations. There is possible to pass `-f` to the options
50 to enable full index rebuild. Without that indexing will run always in in
51 incremental mode.
52
53 ::
54 paster make-index --repo-location=<location for repos> production.ini
55
56 for full index rebuild You can use
57
58 ::
59 paster make-index -f --repo-location=<location for repos> production.ini
46
60
47 - For full text search You can either put crontab entry for
61 - For full text search You can either put crontab entry for
48
62
63 This command can be run even from crontab in order to do periodical
64 index builds and keep Your index always up to date. An example entry might
65 look like this
66
49 ::
67 ::
50
68
51 python /var/www/rhodecode/<rhodecode_installation_path>/lib/indexers/daemon.py incremental <put_here_path_to_repos>
69 /path/to/python/bin/paster --repo-location=<location for repos> /path/to/rhodecode/production.ini
52
70
53 When using incremental mode whoosh will check last modification date of each file
71 When using incremental(default) mode whoosh will check last modification date
54 and add it to reindex if newer file is available. Also indexing daemon checks
72 of each file and add it to reindex if newer file is available. Also indexing
55 for removed files and removes them from index. Sometime You might want to rebuild
73 daemon checks for removed files and removes them from index.
56 index from scrach, in admin pannel You can check `build from scratch` flag
74
57 and in standalone daemon You can pass `full` instead on incremental to build
75 Sometime You might want to rebuild index from scratch. You can do that using
58 remove previos index and build new one.
76 the `-f` flag passed to paster command or, in admin panel You can check
77 `build from scratch` flag.
59
78
60 Nginx virtual host example
79 Nginx virtual host example
61 --------------------------
80 --------------------------
@@ -43,6 +43,7 b' full_stack = true'
43 static_files = false
43 static_files = false
44 lang=en
44 lang=en
45 cache_dir = %(here)s/data
45 cache_dir = %(here)s/data
46 index_dir = %(here)s/data/index
46
47
47 ####################################
48 ####################################
48 ### BEAKER CACHE ####
49 ### BEAKER CACHE ####
@@ -43,6 +43,7 b' full_stack = true'
43 static_files = true
43 static_files = true
44 lang=en
44 lang=en
45 cache_dir = %(here)s/data
45 cache_dir = %(here)s/data
46 index_dir = %(here)s/data/index
46 app_instance_uuid = ${app_instance_uuid}
47 app_instance_uuid = ${app_instance_uuid}
47
48
48 ####################################
49 ####################################
@@ -59,14 +59,14 b' class MakeIndex(command.Command):'
59
59
60 usage = "CONFIG_FILE"
60 usage = "CONFIG_FILE"
61 summary = "Creates index for full text search given configuration file"
61 summary = "Creates index for full text search given configuration file"
62 group_name = "Whoosh indexing"
62 group_name = "RhodeCode"
63
63 takes_config_file = -1
64 parser = command.Command.standard_parser(verbose=True)
64 parser = command.Command.standard_parser(verbose=True)
65 # parser.add_option('--repo-location',
65 parser.add_option('--repo-location',
66 # action='store',
66 action='store',
67 # dest='repo_location',
67 dest='repo_location',
68 # help="Specifies repositories location to index",
68 help="Specifies repositories location to index REQUIRED",
69 # )
69 )
70 parser.add_option('-f',
70 parser.add_option('-f',
71 action='store_true',
71 action='store_true',
72 dest='full_index',
72 dest='full_index',
@@ -75,27 +75,23 b' class MakeIndex(command.Command):'
75 default=False)
75 default=False)
76 def command(self):
76 def command(self):
77 config_name = self.args[0]
77 config_name = self.args[0]
78
79 p = config_name.split('/')
78 p = config_name.split('/')
80 if len(p) == 1:
79 root = '.' if len(p) == 1 else '/'.join(p[:-1])
81 root = '.'
82 else:
83 root = '/'.join(p[:-1])
84 print root
85 config = ConfigParser.ConfigParser({'here':root})
80 config = ConfigParser.ConfigParser({'here':root})
86 config.read(config_name)
81 config.read(config_name)
87 print dict(config.items('app:main'))['index_dir']
82
88 index_location = dict(config.items('app:main'))['index_dir']
83 index_location = dict(config.items('app:main'))['index_dir']
89 #return
84 repo_location = self.options.repo_location
90
85
91 #=======================================================================
86 #======================================================================
92 # WHOOSH DAEMON
87 # WHOOSH DAEMON
93 #=======================================================================
88 #======================================================================
94 from rhodecode.lib.pidlock import LockHeld, DaemonLock
89 from rhodecode.lib.pidlock import LockHeld, DaemonLock
95 from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
90 from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
96 try:
91 try:
97 l = DaemonLock()
92 l = DaemonLock()
98 WhooshIndexingDaemon(index_location=index_location)\
93 WhooshIndexingDaemon(index_location=index_location,
94 repo_location=repo_location)\
99 .run(full_index=self.options.full_index)
95 .run(full_index=self.options.full_index)
100 l.release()
96 l.release()
101 except LockHeld:
97 except LockHeld:
@@ -78,9 +78,7 b' class WhooshIndexingDaemon(object):'
78 if not repo_location:
78 if not repo_location:
79 raise Exception('You have to provide repositories location')
79 raise Exception('You have to provide repositories location')
80
80
81
81 self.repo_paths = HgModel().repo_scan(self.repo_location, None, True)
82
83 self.repo_paths = HgModel.repo_scan('/', self.repo_location, None, True)
84 self.initial = False
82 self.initial = False
85 if not os.path.isdir(self.index_location):
83 if not os.path.isdir(self.index_location):
86 os.mkdir(self.index_location)
84 os.mkdir(self.index_location)
@@ -89,8 +87,7 b' class WhooshIndexingDaemon(object):'
89 self.initial = True
87 self.initial = True
90
88
91 def get_paths(self, repo):
89 def get_paths(self, repo):
92 """
90 """recursive walk in root dir and return a set of all path in that dir
93 recursive walk in root dir and return a set of all path in that dir
94 based on repository walk function
91 based on repository walk function
95 """
92 """
96 index_paths_ = set()
93 index_paths_ = set()
@@ -115,7 +112,8 b' class WhooshIndexingDaemon(object):'
115 return mktime(node.last_changeset.date.timetuple())
112 return mktime(node.last_changeset.date.timetuple())
116
113
117 def add_doc(self, writer, path, repo):
114 def add_doc(self, writer, path, repo):
118 """Adding doc to writer"""
115 """Adding doc to writer this function itself fetches data from
116 the instance of vcs backend"""
119 node = self.get_node(repo, path)
117 node = self.get_node(repo, path)
120
118
121 #we just index the content of chosen files
119 #we just index the content of chosen files
@@ -1,5 +1,5 b''
1 [egg_info]
1 [egg_info]
2 tag_build = rc4
2 tag_build = beta
3 tag_svn_revision = true
3 tag_svn_revision = true
4
4
5 [easy_install]
5 [easy_install]
@@ -89,5 +89,10 b' setup('
89
89
90 [paste.app_install]
90 [paste.app_install]
91 main = pylons.util:PylonsInstaller
91 main = pylons.util:PylonsInstaller
92
93 [paste.global_paster_command]
94 make-index = rhodecode.lib.indexers:MakeIndex
95 upgrade-db = rhodecode.lib.utils:UpgradeDb
96
92 """,
97 """,
93 )
98 )
General Comments 0
You need to be logged in to leave comments. Login now