##// END OF EJS Templates
cli: convert 'gearbox make-index' into 'kallithea-cli index-create'
Thomas De Schampheleire -
r7337:502b9bd0 default
parent child Browse files
Show More
@@ -145,23 +145,23 b' Kallithea provides full text search of r'
145
145
146 For an incremental index build, run::
146 For an incremental index build, run::
147
147
148 gearbox make-index -c my.ini
148 kallithea-cli index-create -c my.ini
149
149
150 For a full index rebuild, run::
150 For a full index rebuild, run::
151
151
152 gearbox make-index -c my.ini -f
152 kallithea-cli index-create -c my.ini --full
153
153
154 The ``--repo-location`` option allows the location of the repositories to be overridden;
154 The ``--repo-location`` option allows the location of the repositories to be overridden;
155 usually, the location is retrieved from the Kallithea database.
155 usually, the location is retrieved from the Kallithea database.
156
156
157 The ``--index-only`` option can be used to limit the indexed repositories to a comma-separated list::
157 The ``--index-only`` option can be used to limit the indexed repositories to a comma-separated list::
158
158
159 gearbox make-index -c my.ini --index-only=vcs,kallithea
159 kallithea-cli index-create -c my.ini --index-only=vcs,kallithea
160
160
161 To keep your index up-to-date it is necessary to do periodic index builds;
161 To keep your index up-to-date it is necessary to do periodic index builds;
162 for this, it is recommended to use a crontab entry. Example::
162 for this, it is recommended to use a crontab entry. Example::
163
163
164 0 3 * * * /path/to/virtualenv/bin/gearbox make-index -c /path/to/kallithea/my.ini
164 0 3 * * * /path/to/virtualenv/bin/kallithea-cli index-create -c /path/to/kallithea/my.ini
165
165
166 When using incremental mode (the default), Whoosh will check the last
166 When using incremental mode (the default), Whoosh will check the last
167 modification date of each file and add it to be reindexed if a newer file is
167 modification date of each file and add it to be reindexed if a newer file is
@@ -20,5 +20,6 b' import kallithea.bin.kallithea_cli_confi'
20 import kallithea.bin.kallithea_cli_db
20 import kallithea.bin.kallithea_cli_db
21 import kallithea.bin.kallithea_cli_extensions
21 import kallithea.bin.kallithea_cli_extensions
22 import kallithea.bin.kallithea_cli_iis
22 import kallithea.bin.kallithea_cli_iis
23 import kallithea.bin.kallithea_cli_index
23 import kallithea.bin.kallithea_cli_ishell
24 import kallithea.bin.kallithea_cli_ishell
24 import kallithea.bin.kallithea_cli_repo
25 import kallithea.bin.kallithea_cli_repo
@@ -12,86 +12,51 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 """
14 """
15 kallithea.lib.paster_commands.make_index
15 This file was forked by the Kallithea project in July 2014 and later moved.
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17
18 make-index gearbox command for Kallithea
19
20 This file was forked by the Kallithea project in July 2014.
21 Original author and date, and relevant copyright and licensing information is below:
16 Original author and date, and relevant copyright and licensing information is below:
22 :created_on: Aug 17, 2010
17 :created_on: Aug 17, 2010
23 :author: marcink
18 :author: marcink
24 :copyright: (c) 2013 RhodeCode GmbH, and others.
19 :copyright: (c) 2013 RhodeCode GmbH, and others.
25 :license: GPLv3, see LICENSE.md for more details.
20 :license: GPLv3, see LICENSE.md for more details.
26 """
21 """
27
22 import click
23 import kallithea.bin.kallithea_cli_base as cli_base
28
24
29 import os
25 import os
26 from string import strip
30 import sys
27 import sys
31
28
32 from string import strip
29 import kallithea
33 from kallithea.model.repo import RepoModel
30 from kallithea.lib.indexers.daemon import WhooshIndexingDaemon
34 from kallithea.lib.paster_commands.common import BasePasterCommand
31 from kallithea.lib.pidlock import LockHeld, DaemonLock
35 from kallithea.lib.utils import load_rcextensions
32 from kallithea.lib.utils import load_rcextensions
36
33 from kallithea.model.repo import RepoModel
37
38 class Command(BasePasterCommand):
39 "Kallithea: Create or update full text search index"
40
34
41 def take_action(self, args):
35 @cli_base.register_command(config_file_initialize_app=True)
42 index_location = self.config['index_dir']
36 @click.option('--repo-location', help='Base path of repositories to index. Default: all')
43 load_rcextensions(self.config['here'])
37 @click.option('--index-only', help='Comma-separated list of repositories to build index on. Default: all')
38 @click.option('--update-only', help='Comma-separated list of repositories to re-build index on. Default: all')
39 @click.option('-f', '--full', 'full_index', help='Recreate the index from scratch')
40 def index_create(repo_location, index_only, update_only, full_index):
41 """Create or update full text search index"""
44
42
45 repo_location = args.repo_location \
43 index_location = kallithea.CONFIG['index_dir']
46 if args.repo_location else RepoModel().repos_path
44 load_rcextensions(kallithea.CONFIG['here'])
47 repo_list = map(strip, args.repo_list.split(',')) \
48 if args.repo_list else None
49
50 repo_update_list = map(strip, args.repo_update_list.split(',')) \
51 if args.repo_update_list else None
52
45
53 #======================================================================
46 if not repo_location:
54 # WHOOSH DAEMON
47 repo_location = RepoModel().repos_path
55 #======================================================================
48 repo_list = map(strip, index_only.split(',')) \
56 from kallithea.lib.pidlock import LockHeld, DaemonLock
49 if index_only else None
57 from kallithea.lib.indexers.daemon import WhooshIndexingDaemon
50 repo_update_list = map(strip, update_only.split(',')) \
58 try:
51 if update_only else None
59 l = DaemonLock(os.path.join(index_location, 'make_index.lock'))
60 WhooshIndexingDaemon(index_location=index_location,
61 repo_location=repo_location,
62 repo_list=repo_list,
63 repo_update_list=repo_update_list) \
64 .run(full_index=args.full_index)
65 l.release()
66 except LockHeld:
67 sys.exit(1)
68
69 def get_parser(self, prog_name):
70 parser = super(Command, self).get_parser(prog_name)
71
52
72 parser.add_argument('--repo-location',
53 try:
73 action='store',
54 l = DaemonLock(os.path.join(index_location, 'make_index.lock'))
74 dest='repo_location',
55 WhooshIndexingDaemon(index_location=index_location,
75 help="Specifies repositories location to index OPTIONAL",
56 repo_location=repo_location,
76 )
57 repo_list=repo_list,
77 parser.add_argument('--index-only',
58 repo_update_list=repo_update_list) \
78 action='store',
59 .run(full_index=full_index)
79 dest='repo_list',
60 l.release()
80 help="Specifies a comma separated list of repositories "
61 except LockHeld:
81 "to build index on. If not given all repositories "
62 sys.exit(1)
82 "are scanned for indexing. OPTIONAL",
83 )
84 parser.add_argument('--update-only',
85 action='store',
86 dest='repo_update_list',
87 help="Specifies a comma separated list of repositories "
88 "to re-build index on. OPTIONAL",
89 )
90 parser.add_argument('-f',
91 action='store_true',
92 dest='full_index',
93 help="Specifies that index should be made full i.e"
94 " destroy old and build from scratch",
95 default=False)
96
97 return parser
@@ -160,7 +160,6 b' setuptools.setup('
160
160
161 [gearbox.commands]
161 [gearbox.commands]
162 celeryd=kallithea.lib.paster_commands.celeryd:Command
162 celeryd=kallithea.lib.paster_commands.celeryd:Command
163 make-index=kallithea.lib.paster_commands.make_index:Command
164 upgrade-db=kallithea.lib.dbmigrate:UpgradeDb
163 upgrade-db=kallithea.lib.dbmigrate:UpgradeDb
165 """,
164 """,
166 )
165 )
General Comments 0
You need to be logged in to leave comments. Login now