##// END OF EJS Templates
cli: convert 'gearbox celeryd' into 'kallithea-cli celery-run'...
Thomas De Schampheleire -
r7338:1d539bb1 default
parent child Browse files
Show More
@@ -1,599 +1,599 b''
1 .. _setup:
1 .. _setup:
2
2
3 =====
3 =====
4 Setup
4 Setup
5 =====
5 =====
6
6
7
7
8 Preparing front-end
8 Preparing front-end
9 -------------------
9 -------------------
10
10
11 Temporarily, in the current Kallithea version, some extra steps are required to
11 Temporarily, in the current Kallithea version, some extra steps are required to
12 build front-end files:
12 build front-end files:
13
13
14 Find the right ``kallithea/public/less`` path with::
14 Find the right ``kallithea/public/less`` path with::
15
15
16 python -c "import os, kallithea; print os.path.join(os.path.dirname(os.path.abspath(kallithea.__file__)), 'public', 'less')"
16 python -c "import os, kallithea; print os.path.join(os.path.dirname(os.path.abspath(kallithea.__file__)), 'public', 'less')"
17
17
18 Then run::
18 Then run::
19
19
20 npm install
20 npm install
21 npm run less
21 npm run less
22
22
23
23
24 Setting up Kallithea
24 Setting up Kallithea
25 --------------------
25 --------------------
26
26
27 First, you will need to create a Kallithea configuration file. Run the
27 First, you will need to create a Kallithea configuration file. Run the
28 following command to do so::
28 following command to do so::
29
29
30 kallithea-cli config-create my.ini
30 kallithea-cli config-create my.ini
31
31
32 This will create the file ``my.ini`` in the current directory. This
32 This will create the file ``my.ini`` in the current directory. This
33 configuration file contains the various settings for Kallithea, e.g.
33 configuration file contains the various settings for Kallithea, e.g.
34 proxy port, email settings, usage of static files, cache, Celery
34 proxy port, email settings, usage of static files, cache, Celery
35 settings, and logging. Extra settings can be specified like::
35 settings, and logging. Extra settings can be specified like::
36
36
37 kallithea-cli config-create my.ini host=8.8.8.8 "[handler_console]" formatter=color_formatter
37 kallithea-cli config-create my.ini host=8.8.8.8 "[handler_console]" formatter=color_formatter
38
38
39 Next, you need to create the databases used by Kallithea. It is recommended to
39 Next, you need to create the databases used by Kallithea. It is recommended to
40 use PostgreSQL or SQLite (default). If you choose a database other than the
40 use PostgreSQL or SQLite (default). If you choose a database other than the
41 default, ensure you properly adjust the database URL in your ``my.ini``
41 default, ensure you properly adjust the database URL in your ``my.ini``
42 configuration file to use this other database. Kallithea currently supports
42 configuration file to use this other database. Kallithea currently supports
43 PostgreSQL, SQLite and MySQL databases. Create the database by running
43 PostgreSQL, SQLite and MySQL databases. Create the database by running
44 the following command::
44 the following command::
45
45
46 kallithea-cli db-create -c my.ini
46 kallithea-cli db-create -c my.ini
47
47
48 This will prompt you for a "root" path. This "root" path is the location where
48 This will prompt you for a "root" path. This "root" path is the location where
49 Kallithea will store all of its repositories on the current machine. After
49 Kallithea will store all of its repositories on the current machine. After
50 entering this "root" path ``db-create`` will also prompt you for a username
50 entering this "root" path ``db-create`` will also prompt you for a username
51 and password for the initial admin account which ``db-create`` sets
51 and password for the initial admin account which ``db-create`` sets
52 up for you.
52 up for you.
53
53
54 The ``db-create`` values can also be given on the command line.
54 The ``db-create`` values can also be given on the command line.
55 Example::
55 Example::
56
56
57 kallithea-cli db-create -c my.ini --user=nn --password=secret --email=nn@example.com --repos=/srv/repos
57 kallithea-cli db-create -c my.ini --user=nn --password=secret --email=nn@example.com --repos=/srv/repos
58
58
59 The ``db-create`` command will create all needed tables and an
59 The ``db-create`` command will create all needed tables and an
60 admin account. When choosing a root path you can either use a new
60 admin account. When choosing a root path you can either use a new
61 empty location, or a location which already contains existing
61 empty location, or a location which already contains existing
62 repositories. If you choose a location which contains existing
62 repositories. If you choose a location which contains existing
63 repositories Kallithea will add all of the repositories at the chosen
63 repositories Kallithea will add all of the repositories at the chosen
64 location to its database. (Note: make sure you specify the correct
64 location to its database. (Note: make sure you specify the correct
65 path to the root).
65 path to the root).
66
66
67 .. note:: the given path for Mercurial_ repositories **must** be write
67 .. note:: the given path for Mercurial_ repositories **must** be write
68 accessible for the application. It's very important since
68 accessible for the application. It's very important since
69 the Kallithea web interface will work without write access,
69 the Kallithea web interface will work without write access,
70 but when trying to do a push it will fail with permission
70 but when trying to do a push it will fail with permission
71 denied errors unless it has write access.
71 denied errors unless it has write access.
72
72
73 You are now ready to use Kallithea. To run it simply execute::
73 You are now ready to use Kallithea. To run it simply execute::
74
74
75 gearbox serve -c my.ini
75 gearbox serve -c my.ini
76
76
77 - This command runs the Kallithea server. The web app should be available at
77 - This command runs the Kallithea server. The web app should be available at
78 http://127.0.0.1:5000. The IP address and port is configurable via the
78 http://127.0.0.1:5000. The IP address and port is configurable via the
79 configuration file created in the previous step.
79 configuration file created in the previous step.
80 - Log in to Kallithea using the admin account created when running ``db-create``.
80 - Log in to Kallithea using the admin account created when running ``db-create``.
81 - The default permissions on each repository is read, and the owner is admin.
81 - The default permissions on each repository is read, and the owner is admin.
82 Remember to update these if needed.
82 Remember to update these if needed.
83 - In the admin panel you can toggle LDAP, anonymous, and permissions
83 - In the admin panel you can toggle LDAP, anonymous, and permissions
84 settings, as well as edit more advanced options on users and
84 settings, as well as edit more advanced options on users and
85 repositories.
85 repositories.
86
86
87
87
88 Internationalization (i18n support)
88 Internationalization (i18n support)
89 -----------------------------------
89 -----------------------------------
90
90
91 The Kallithea web interface is automatically displayed in the user's preferred
91 The Kallithea web interface is automatically displayed in the user's preferred
92 language, as indicated by the browser. Thus, different users may see the
92 language, as indicated by the browser. Thus, different users may see the
93 application in different languages. If the requested language is not available
93 application in different languages. If the requested language is not available
94 (because the translation file for that language does not yet exist or is
94 (because the translation file for that language does not yet exist or is
95 incomplete), the language specified in setting ``i18n.lang`` in the Kallithea
95 incomplete), the language specified in setting ``i18n.lang`` in the Kallithea
96 configuration file is used as fallback. If no fallback language is explicitly
96 configuration file is used as fallback. If no fallback language is explicitly
97 specified, English is used.
97 specified, English is used.
98
98
99 If you want to disable automatic language detection and instead configure a
99 If you want to disable automatic language detection and instead configure a
100 fixed language regardless of user preference, set ``i18n.enabled = false`` and
100 fixed language regardless of user preference, set ``i18n.enabled = false`` and
101 set ``i18n.lang`` to the desired language (or leave empty for English).
101 set ``i18n.lang`` to the desired language (or leave empty for English).
102
102
103
103
104 Using Kallithea with SSH
104 Using Kallithea with SSH
105 ------------------------
105 ------------------------
106
106
107 Kallithea currently only hosts repositories using http and https. (The addition
107 Kallithea currently only hosts repositories using http and https. (The addition
108 of ssh hosting is a planned future feature.) However you can easily use ssh in
108 of ssh hosting is a planned future feature.) However you can easily use ssh in
109 parallel with Kallithea. (Repository access via ssh is a standard "out of
109 parallel with Kallithea. (Repository access via ssh is a standard "out of
110 the box" feature of Mercurial_ and you can use this to access any of the
110 the box" feature of Mercurial_ and you can use this to access any of the
111 repositories that Kallithea is hosting. See PublishingRepositories_)
111 repositories that Kallithea is hosting. See PublishingRepositories_)
112
112
113 Kallithea repository structures are kept in directories with the same name
113 Kallithea repository structures are kept in directories with the same name
114 as the project. When using repository groups, each group is a subdirectory.
114 as the project. When using repository groups, each group is a subdirectory.
115 This allows you to easily use ssh for accessing repositories.
115 This allows you to easily use ssh for accessing repositories.
116
116
117 In order to use ssh you need to make sure that your web server and the users'
117 In order to use ssh you need to make sure that your web server and the users'
118 login accounts have the correct permissions set on the appropriate directories.
118 login accounts have the correct permissions set on the appropriate directories.
119
119
120 .. note:: These permissions are independent of any permissions you
120 .. note:: These permissions are independent of any permissions you
121 have set up using the Kallithea web interface.
121 have set up using the Kallithea web interface.
122
122
123 If your main directory (the same as set in Kallithea settings) is for
123 If your main directory (the same as set in Kallithea settings) is for
124 example set to ``/srv/repos`` and the repository you are using is
124 example set to ``/srv/repos`` and the repository you are using is
125 named ``kallithea``, then to clone via ssh you should run::
125 named ``kallithea``, then to clone via ssh you should run::
126
126
127 hg clone ssh://user@kallithea.example.com/srv/repos/kallithea
127 hg clone ssh://user@kallithea.example.com/srv/repos/kallithea
128
128
129 Using other external tools such as mercurial-server_ or using ssh key-based
129 Using other external tools such as mercurial-server_ or using ssh key-based
130 authentication is fully supported.
130 authentication is fully supported.
131
131
132 .. note:: In an advanced setup, in order for your ssh access to use
132 .. note:: In an advanced setup, in order for your ssh access to use
133 the same permissions as set up via the Kallithea web
133 the same permissions as set up via the Kallithea web
134 interface, you can create an authentication hook to connect
134 interface, you can create an authentication hook to connect
135 to the Kallithea db and run check functions for permissions
135 to the Kallithea db and run check functions for permissions
136 against that.
136 against that.
137
137
138
138
139 Setting up Whoosh full text search
139 Setting up Whoosh full text search
140 ----------------------------------
140 ----------------------------------
141
141
142 Kallithea provides full text search of repositories using `Whoosh`__.
142 Kallithea provides full text search of repositories using `Whoosh`__.
143
143
144 .. __: https://whoosh.readthedocs.io/en/latest/
144 .. __: https://whoosh.readthedocs.io/en/latest/
145
145
146 For an incremental index build, run::
146 For an incremental index build, run::
147
147
148 kallithea-cli index-create -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 kallithea-cli index-create -c my.ini --full
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 kallithea-cli index-create -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/kallithea-cli index-create -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
168 available. The indexing daemon checks for any removed files and removes them
168 available. The indexing daemon checks for any removed files and removes them
169 from index.
169 from index.
170
170
171 If you want to rebuild the index from scratch, you can use the ``-f`` flag as above,
171 If you want to rebuild the index from scratch, you can use the ``-f`` flag as above,
172 or in the admin panel you can check the "build from scratch" checkbox.
172 or in the admin panel you can check the "build from scratch" checkbox.
173
173
174
174
175 Integration with issue trackers
175 Integration with issue trackers
176 -------------------------------
176 -------------------------------
177
177
178 Kallithea provides a simple integration with issue trackers. It's possible
178 Kallithea provides a simple integration with issue trackers. It's possible
179 to define a regular expression that will match an issue ID in commit messages,
179 to define a regular expression that will match an issue ID in commit messages,
180 and have that replaced with a URL to the issue.
180 and have that replaced with a URL to the issue.
181
181
182 This is achieved with following three variables in the ini file::
182 This is achieved with following three variables in the ini file::
183
183
184 issue_pat = #(\d+)
184 issue_pat = #(\d+)
185 issue_server_link = https://issues.example.com/{repo}/issue/\1
185 issue_server_link = https://issues.example.com/{repo}/issue/\1
186 issue_sub =
186 issue_sub =
187
187
188 ``issue_pat`` is the regular expression describing which strings in
188 ``issue_pat`` is the regular expression describing which strings in
189 commit messages will be treated as issue references. The expression can/should
189 commit messages will be treated as issue references. The expression can/should
190 have one or more parenthesized groups that can later be referred to in
190 have one or more parenthesized groups that can later be referred to in
191 ``issue_server_link`` and ``issue_sub`` (see below). If you prefer, named groups
191 ``issue_server_link`` and ``issue_sub`` (see below). If you prefer, named groups
192 can be used instead of simple parenthesized groups.
192 can be used instead of simple parenthesized groups.
193
193
194 If the pattern should only match if it is preceded by whitespace, add the
194 If the pattern should only match if it is preceded by whitespace, add the
195 following string before the actual pattern: ``(?:^|(?<=\s))``.
195 following string before the actual pattern: ``(?:^|(?<=\s))``.
196 If the pattern should only match if it is followed by whitespace, add the
196 If the pattern should only match if it is followed by whitespace, add the
197 following string after the actual pattern: ``(?:$|(?=\s))``.
197 following string after the actual pattern: ``(?:$|(?=\s))``.
198 These expressions use lookbehind and lookahead assertions of the Python regular
198 These expressions use lookbehind and lookahead assertions of the Python regular
199 expression module to avoid the whitespace to be part of the actual pattern,
199 expression module to avoid the whitespace to be part of the actual pattern,
200 otherwise the link text will also contain that whitespace.
200 otherwise the link text will also contain that whitespace.
201
201
202 Matched issue references are replaced with the link specified in
202 Matched issue references are replaced with the link specified in
203 ``issue_server_link``, in which any backreferences are resolved. Backreferences
203 ``issue_server_link``, in which any backreferences are resolved. Backreferences
204 can be ``\1``, ``\2``, ... or for named groups ``\g<groupname>``.
204 can be ``\1``, ``\2``, ... or for named groups ``\g<groupname>``.
205 The special token ``{repo}`` is replaced with the full repository path
205 The special token ``{repo}`` is replaced with the full repository path
206 (including repository groups), while token ``{repo_name}`` is replaced with the
206 (including repository groups), while token ``{repo_name}`` is replaced with the
207 repository name (without repository groups).
207 repository name (without repository groups).
208
208
209 The link text is determined by ``issue_sub``, which can be a string containing
209 The link text is determined by ``issue_sub``, which can be a string containing
210 backreferences to the groups specified in ``issue_pat``. If ``issue_sub`` is
210 backreferences to the groups specified in ``issue_pat``. If ``issue_sub`` is
211 empty, then the text matched by ``issue_pat`` is used verbatim.
211 empty, then the text matched by ``issue_pat`` is used verbatim.
212
212
213 The example settings shown above match issues in the format ``#<number>``.
213 The example settings shown above match issues in the format ``#<number>``.
214 This will cause the text ``#300`` to be transformed into a link:
214 This will cause the text ``#300`` to be transformed into a link:
215
215
216 .. code-block:: html
216 .. code-block:: html
217
217
218 <a href="https://issues.example.com/example_repo/issue/300">#300</a>
218 <a href="https://issues.example.com/example_repo/issue/300">#300</a>
219
219
220 The following example transforms a text starting with either of 'pullrequest',
220 The following example transforms a text starting with either of 'pullrequest',
221 'pull request' or 'PR', followed by an optional space, then a pound character
221 'pull request' or 'PR', followed by an optional space, then a pound character
222 (#) and one or more digits, into a link with the text 'PR #' followed by the
222 (#) and one or more digits, into a link with the text 'PR #' followed by the
223 digits::
223 digits::
224
224
225 issue_pat = (pullrequest|pull request|PR) ?#(\d+)
225 issue_pat = (pullrequest|pull request|PR) ?#(\d+)
226 issue_server_link = https://issues.example.com/\2
226 issue_server_link = https://issues.example.com/\2
227 issue_sub = PR #\2
227 issue_sub = PR #\2
228
228
229 The following example demonstrates how to require whitespace before the issue
229 The following example demonstrates how to require whitespace before the issue
230 reference in order for it to be recognized, such that the text ``issue#123`` will
230 reference in order for it to be recognized, such that the text ``issue#123`` will
231 not cause a match, but ``issue #123`` will::
231 not cause a match, but ``issue #123`` will::
232
232
233 issue_pat = (?:^|(?<=\s))#(\d+)
233 issue_pat = (?:^|(?<=\s))#(\d+)
234 issue_server_link = https://issues.example.com/\1
234 issue_server_link = https://issues.example.com/\1
235 issue_sub =
235 issue_sub =
236
236
237 If needed, more than one pattern can be specified by appending a unique suffix to
237 If needed, more than one pattern can be specified by appending a unique suffix to
238 the variables. For example, also demonstrating the use of named groups::
238 the variables. For example, also demonstrating the use of named groups::
239
239
240 issue_pat_wiki = wiki-(?P<pagename>\S+)
240 issue_pat_wiki = wiki-(?P<pagename>\S+)
241 issue_server_link_wiki = https://wiki.example.com/\g<pagename>
241 issue_server_link_wiki = https://wiki.example.com/\g<pagename>
242 issue_sub_wiki = WIKI-\g<pagename>
242 issue_sub_wiki = WIKI-\g<pagename>
243
243
244 With these settings, wiki pages can be referenced as wiki-some-id, and every
244 With these settings, wiki pages can be referenced as wiki-some-id, and every
245 such reference will be transformed into:
245 such reference will be transformed into:
246
246
247 .. code-block:: html
247 .. code-block:: html
248
248
249 <a href="https://wiki.example.com/some-id">WIKI-some-id</a>
249 <a href="https://wiki.example.com/some-id">WIKI-some-id</a>
250
250
251 Refer to the `Python regular expression documentation`_ for more details about
251 Refer to the `Python regular expression documentation`_ for more details about
252 the supported syntax in ``issue_pat``, ``issue_server_link`` and ``issue_sub``.
252 the supported syntax in ``issue_pat``, ``issue_server_link`` and ``issue_sub``.
253
253
254
254
255 Hook management
255 Hook management
256 ---------------
256 ---------------
257
257
258 Hooks can be managed in similar way to that used in ``.hgrc`` files.
258 Hooks can be managed in similar way to that used in ``.hgrc`` files.
259 To manage hooks, choose *Admin > Settings > Hooks*.
259 To manage hooks, choose *Admin > Settings > Hooks*.
260
260
261 The built-in hooks cannot be modified, though they can be enabled or disabled in the *VCS* section.
261 The built-in hooks cannot be modified, though they can be enabled or disabled in the *VCS* section.
262
262
263 To add another custom hook simply fill in the first textbox with
263 To add another custom hook simply fill in the first textbox with
264 ``<name>.<hook_type>`` and the second with the hook path. Example hooks
264 ``<name>.<hook_type>`` and the second with the hook path. Example hooks
265 can be found in ``kallithea.lib.hooks``.
265 can be found in ``kallithea.lib.hooks``.
266
266
267
267
268 Changing default encoding
268 Changing default encoding
269 -------------------------
269 -------------------------
270
270
271 By default, Kallithea uses UTF-8 encoding.
271 By default, Kallithea uses UTF-8 encoding.
272 This is configurable as ``default_encoding`` in the .ini file.
272 This is configurable as ``default_encoding`` in the .ini file.
273 This affects many parts in Kallithea including user names, filenames, and
273 This affects many parts in Kallithea including user names, filenames, and
274 encoding of commit messages. In addition Kallithea can detect if the ``chardet``
274 encoding of commit messages. In addition Kallithea can detect if the ``chardet``
275 library is installed. If ``chardet`` is detected Kallithea will fallback to it
275 library is installed. If ``chardet`` is detected Kallithea will fallback to it
276 when there are encode/decode errors.
276 when there are encode/decode errors.
277
277
278 The Mercurial encoding is configurable as ``hgencoding``. It is similar to
278 The Mercurial encoding is configurable as ``hgencoding``. It is similar to
279 setting the ``HGENCODING`` environment variable, but will override it.
279 setting the ``HGENCODING`` environment variable, but will override it.
280
280
281
281
282 Celery configuration
282 Celery configuration
283 --------------------
283 --------------------
284
284
285 Kallithea can use the distributed task queue system Celery_ to run tasks like
285 Kallithea can use the distributed task queue system Celery_ to run tasks like
286 cloning repositories or sending emails.
286 cloning repositories or sending emails.
287
287
288 Kallithea will in most setups work perfectly fine out of the box (without
288 Kallithea will in most setups work perfectly fine out of the box (without
289 Celery), executing all tasks in the web server process. Some tasks can however
289 Celery), executing all tasks in the web server process. Some tasks can however
290 take some time to run and it can be better to run such tasks asynchronously in
290 take some time to run and it can be better to run such tasks asynchronously in
291 a separate process so the web server can focus on serving web requests.
291 a separate process so the web server can focus on serving web requests.
292
292
293 For installation and configuration of Celery, see the `Celery documentation`_.
293 For installation and configuration of Celery, see the `Celery documentation`_.
294 Note that Celery requires a message broker service like RabbitMQ_ (recommended)
294 Note that Celery requires a message broker service like RabbitMQ_ (recommended)
295 or Redis_.
295 or Redis_.
296
296
297 The use of Celery is configured in the Kallithea ini configuration file.
297 The use of Celery is configured in the Kallithea ini configuration file.
298 To enable it, simply set::
298 To enable it, simply set::
299
299
300 use_celery = true
300 use_celery = true
301
301
302 and add or change the ``celery.*`` and ``broker.*`` configuration variables.
302 and add or change the ``celery.*`` and ``broker.*`` configuration variables.
303
303
304 Remember that the ini files use the format with '.' and not with '_' like
304 Remember that the ini files use the format with '.' and not with '_' like
305 Celery. So for example setting `BROKER_HOST` in Celery means setting
305 Celery. So for example setting `BROKER_HOST` in Celery means setting
306 `broker.host` in the configuration file.
306 `broker.host` in the configuration file.
307
307
308 To start the Celery process, run::
308 To start the Celery process, run::
309
309
310 gearbox celeryd -c my.ini
310 kallithea-cli celery-run -c my.ini
311
311
312 Extra options to the Celery worker can be passed after ``--`` - see ``-- -h``
312 Extra options to the Celery worker can be passed after ``--`` - see ``-- -h``
313 for more info.
313 for more info.
314
314
315 .. note::
315 .. note::
316 Make sure you run this command from the same virtualenv, and with the same
316 Make sure you run this command from the same virtualenv, and with the same
317 user that Kallithea runs.
317 user that Kallithea runs.
318
318
319
319
320 HTTPS support
320 HTTPS support
321 -------------
321 -------------
322
322
323 Kallithea will by default generate URLs based on the WSGI environment.
323 Kallithea will by default generate URLs based on the WSGI environment.
324
324
325 Alternatively, you can use some special configuration settings to control
325 Alternatively, you can use some special configuration settings to control
326 directly which scheme/protocol Kallithea will use when generating URLs:
326 directly which scheme/protocol Kallithea will use when generating URLs:
327
327
328 - With ``https_fixup = true``, the scheme will be taken from the
328 - With ``https_fixup = true``, the scheme will be taken from the
329 ``X-Url-Scheme``, ``X-Forwarded-Scheme`` or ``X-Forwarded-Proto`` HTTP header
329 ``X-Url-Scheme``, ``X-Forwarded-Scheme`` or ``X-Forwarded-Proto`` HTTP header
330 (default ``http``).
330 (default ``http``).
331 - With ``force_https = true`` the default will be ``https``.
331 - With ``force_https = true`` the default will be ``https``.
332 - With ``use_htsts = true``, Kallithea will set ``Strict-Transport-Security`` when using https.
332 - With ``use_htsts = true``, Kallithea will set ``Strict-Transport-Security`` when using https.
333
333
334 .. _nginx_virtual_host:
334 .. _nginx_virtual_host:
335
335
336
336
337 Nginx virtual host example
337 Nginx virtual host example
338 --------------------------
338 --------------------------
339
339
340 Sample config for Nginx using proxy:
340 Sample config for Nginx using proxy:
341
341
342 .. code-block:: nginx
342 .. code-block:: nginx
343
343
344 upstream kallithea {
344 upstream kallithea {
345 server 127.0.0.1:5000;
345 server 127.0.0.1:5000;
346 # add more instances for load balancing
346 # add more instances for load balancing
347 #server 127.0.0.1:5001;
347 #server 127.0.0.1:5001;
348 #server 127.0.0.1:5002;
348 #server 127.0.0.1:5002;
349 }
349 }
350
350
351 ## gist alias
351 ## gist alias
352 server {
352 server {
353 listen 443;
353 listen 443;
354 server_name gist.example.com;
354 server_name gist.example.com;
355 access_log /var/log/nginx/gist.access.log;
355 access_log /var/log/nginx/gist.access.log;
356 error_log /var/log/nginx/gist.error.log;
356 error_log /var/log/nginx/gist.error.log;
357
357
358 ssl on;
358 ssl on;
359 ssl_certificate gist.your.kallithea.server.crt;
359 ssl_certificate gist.your.kallithea.server.crt;
360 ssl_certificate_key gist.your.kallithea.server.key;
360 ssl_certificate_key gist.your.kallithea.server.key;
361
361
362 ssl_session_timeout 5m;
362 ssl_session_timeout 5m;
363
363
364 ssl_protocols SSLv3 TLSv1;
364 ssl_protocols SSLv3 TLSv1;
365 ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5;
365 ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5;
366 ssl_prefer_server_ciphers on;
366 ssl_prefer_server_ciphers on;
367
367
368 rewrite ^/(.+)$ https://kallithea.example.com/_admin/gists/$1;
368 rewrite ^/(.+)$ https://kallithea.example.com/_admin/gists/$1;
369 rewrite (.*) https://kallithea.example.com/_admin/gists;
369 rewrite (.*) https://kallithea.example.com/_admin/gists;
370 }
370 }
371
371
372 server {
372 server {
373 listen 443;
373 listen 443;
374 server_name kallithea.example.com
374 server_name kallithea.example.com
375 access_log /var/log/nginx/kallithea.access.log;
375 access_log /var/log/nginx/kallithea.access.log;
376 error_log /var/log/nginx/kallithea.error.log;
376 error_log /var/log/nginx/kallithea.error.log;
377
377
378 ssl on;
378 ssl on;
379 ssl_certificate your.kallithea.server.crt;
379 ssl_certificate your.kallithea.server.crt;
380 ssl_certificate_key your.kallithea.server.key;
380 ssl_certificate_key your.kallithea.server.key;
381
381
382 ssl_session_timeout 5m;
382 ssl_session_timeout 5m;
383
383
384 ssl_protocols SSLv3 TLSv1;
384 ssl_protocols SSLv3 TLSv1;
385 ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5;
385 ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5;
386 ssl_prefer_server_ciphers on;
386 ssl_prefer_server_ciphers on;
387
387
388 ## uncomment root directive if you want to serve static files by nginx
388 ## uncomment root directive if you want to serve static files by nginx
389 ## requires static_files = false in .ini file
389 ## requires static_files = false in .ini file
390 #root /srv/kallithea/kallithea/kallithea/public;
390 #root /srv/kallithea/kallithea/kallithea/public;
391 include /etc/nginx/proxy.conf;
391 include /etc/nginx/proxy.conf;
392 location / {
392 location / {
393 try_files $uri @kallithea;
393 try_files $uri @kallithea;
394 }
394 }
395
395
396 location @kallithea {
396 location @kallithea {
397 proxy_pass http://127.0.0.1:5000;
397 proxy_pass http://127.0.0.1:5000;
398 }
398 }
399
399
400 }
400 }
401
401
402 Here's the proxy.conf. It's tuned so it will not timeout on long
402 Here's the proxy.conf. It's tuned so it will not timeout on long
403 pushes or large pushes::
403 pushes or large pushes::
404
404
405 proxy_redirect off;
405 proxy_redirect off;
406 proxy_set_header Host $host;
406 proxy_set_header Host $host;
407 ## needed for container auth
407 ## needed for container auth
408 #proxy_set_header REMOTE_USER $remote_user;
408 #proxy_set_header REMOTE_USER $remote_user;
409 #proxy_set_header X-Forwarded-User $remote_user;
409 #proxy_set_header X-Forwarded-User $remote_user;
410 proxy_set_header X-Url-Scheme $scheme;
410 proxy_set_header X-Url-Scheme $scheme;
411 proxy_set_header X-Host $http_host;
411 proxy_set_header X-Host $http_host;
412 proxy_set_header X-Real-IP $remote_addr;
412 proxy_set_header X-Real-IP $remote_addr;
413 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
413 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
414 proxy_set_header Proxy-host $proxy_host;
414 proxy_set_header Proxy-host $proxy_host;
415 proxy_buffering off;
415 proxy_buffering off;
416 proxy_connect_timeout 7200;
416 proxy_connect_timeout 7200;
417 proxy_send_timeout 7200;
417 proxy_send_timeout 7200;
418 proxy_read_timeout 7200;
418 proxy_read_timeout 7200;
419 proxy_buffers 8 32k;
419 proxy_buffers 8 32k;
420 client_max_body_size 1024m;
420 client_max_body_size 1024m;
421 client_body_buffer_size 128k;
421 client_body_buffer_size 128k;
422 large_client_header_buffers 8 64k;
422 large_client_header_buffers 8 64k;
423
423
424 .. _apache_virtual_host_reverse_proxy:
424 .. _apache_virtual_host_reverse_proxy:
425
425
426
426
427 Apache virtual host reverse proxy example
427 Apache virtual host reverse proxy example
428 -----------------------------------------
428 -----------------------------------------
429
429
430 Here is a sample configuration file for Apache using proxy:
430 Here is a sample configuration file for Apache using proxy:
431
431
432 .. code-block:: apache
432 .. code-block:: apache
433
433
434 <VirtualHost *:80>
434 <VirtualHost *:80>
435 ServerName kallithea.example.com
435 ServerName kallithea.example.com
436
436
437 <Proxy *>
437 <Proxy *>
438 # For Apache 2.4 and later:
438 # For Apache 2.4 and later:
439 Require all granted
439 Require all granted
440
440
441 # For Apache 2.2 and earlier, instead use:
441 # For Apache 2.2 and earlier, instead use:
442 # Order allow,deny
442 # Order allow,deny
443 # Allow from all
443 # Allow from all
444 </Proxy>
444 </Proxy>
445
445
446 #important !
446 #important !
447 #Directive to properly generate url (clone url) for Kallithea
447 #Directive to properly generate url (clone url) for Kallithea
448 ProxyPreserveHost On
448 ProxyPreserveHost On
449
449
450 #kallithea instance
450 #kallithea instance
451 ProxyPass / http://127.0.0.1:5000/
451 ProxyPass / http://127.0.0.1:5000/
452 ProxyPassReverse / http://127.0.0.1:5000/
452 ProxyPassReverse / http://127.0.0.1:5000/
453
453
454 #to enable https use line below
454 #to enable https use line below
455 #SetEnvIf X-Url-Scheme https HTTPS=1
455 #SetEnvIf X-Url-Scheme https HTTPS=1
456 </VirtualHost>
456 </VirtualHost>
457
457
458 Additional tutorial
458 Additional tutorial
459 http://pylonsbook.com/en/1.1/deployment.html#using-apache-to-proxy-requests-to-pylons
459 http://pylonsbook.com/en/1.1/deployment.html#using-apache-to-proxy-requests-to-pylons
460
460
461 .. _apache_subdirectory:
461 .. _apache_subdirectory:
462
462
463
463
464 Apache as subdirectory
464 Apache as subdirectory
465 ----------------------
465 ----------------------
466
466
467 Apache subdirectory part:
467 Apache subdirectory part:
468
468
469 .. code-block:: apache
469 .. code-block:: apache
470
470
471 <Location /PREFIX >
471 <Location /PREFIX >
472 ProxyPass http://127.0.0.1:5000/PREFIX
472 ProxyPass http://127.0.0.1:5000/PREFIX
473 ProxyPassReverse http://127.0.0.1:5000/PREFIX
473 ProxyPassReverse http://127.0.0.1:5000/PREFIX
474 SetEnvIf X-Url-Scheme https HTTPS=1
474 SetEnvIf X-Url-Scheme https HTTPS=1
475 </Location>
475 </Location>
476
476
477 Besides the regular apache setup you will need to add the following line
477 Besides the regular apache setup you will need to add the following line
478 into ``[app:main]`` section of your .ini file::
478 into ``[app:main]`` section of your .ini file::
479
479
480 filter-with = proxy-prefix
480 filter-with = proxy-prefix
481
481
482 Add the following at the end of the .ini file::
482 Add the following at the end of the .ini file::
483
483
484 [filter:proxy-prefix]
484 [filter:proxy-prefix]
485 use = egg:PasteDeploy#prefix
485 use = egg:PasteDeploy#prefix
486 prefix = /PREFIX
486 prefix = /PREFIX
487
487
488 then change ``PREFIX`` into your chosen prefix
488 then change ``PREFIX`` into your chosen prefix
489
489
490 .. _apache_mod_wsgi:
490 .. _apache_mod_wsgi:
491
491
492
492
493 Apache with mod_wsgi
493 Apache with mod_wsgi
494 --------------------
494 --------------------
495
495
496 Alternatively, Kallithea can be set up with Apache under mod_wsgi. For
496 Alternatively, Kallithea can be set up with Apache under mod_wsgi. For
497 that, you'll need to:
497 that, you'll need to:
498
498
499 - Install mod_wsgi. If using a Debian-based distro, you can install
499 - Install mod_wsgi. If using a Debian-based distro, you can install
500 the package libapache2-mod-wsgi::
500 the package libapache2-mod-wsgi::
501
501
502 aptitude install libapache2-mod-wsgi
502 aptitude install libapache2-mod-wsgi
503
503
504 - Enable mod_wsgi::
504 - Enable mod_wsgi::
505
505
506 a2enmod wsgi
506 a2enmod wsgi
507
507
508 - Add global Apache configuration to tell mod_wsgi that Python only will be
508 - Add global Apache configuration to tell mod_wsgi that Python only will be
509 used in the WSGI processes and shouldn't be initialized in the Apache
509 used in the WSGI processes and shouldn't be initialized in the Apache
510 processes::
510 processes::
511
511
512 WSGIRestrictEmbedded On
512 WSGIRestrictEmbedded On
513
513
514 - Create a wsgi dispatch script, like the one below. Make sure you
514 - Create a wsgi dispatch script, like the one below. Make sure you
515 check that the paths correctly point to where you installed Kallithea
515 check that the paths correctly point to where you installed Kallithea
516 and its Python Virtual Environment.
516 and its Python Virtual Environment.
517 - Enable the ``WSGIScriptAlias`` directive for the WSGI dispatch script,
517 - Enable the ``WSGIScriptAlias`` directive for the WSGI dispatch script,
518 as in the following example. Once again, check the paths are
518 as in the following example. Once again, check the paths are
519 correctly specified.
519 correctly specified.
520
520
521 Here is a sample excerpt from an Apache Virtual Host configuration file:
521 Here is a sample excerpt from an Apache Virtual Host configuration file:
522
522
523 .. code-block:: apache
523 .. code-block:: apache
524
524
525 WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 \
525 WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 \
526 python-home=/srv/kallithea/venv
526 python-home=/srv/kallithea/venv
527 WSGIProcessGroup kallithea
527 WSGIProcessGroup kallithea
528 WSGIScriptAlias / /srv/kallithea/dispatch.wsgi
528 WSGIScriptAlias / /srv/kallithea/dispatch.wsgi
529 WSGIPassAuthorization On
529 WSGIPassAuthorization On
530
530
531 Or if using a dispatcher WSGI script with proper virtualenv activation:
531 Or if using a dispatcher WSGI script with proper virtualenv activation:
532
532
533 .. code-block:: apache
533 .. code-block:: apache
534
534
535 WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100
535 WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100
536 WSGIProcessGroup kallithea
536 WSGIProcessGroup kallithea
537 WSGIScriptAlias / /srv/kallithea/dispatch.wsgi
537 WSGIScriptAlias / /srv/kallithea/dispatch.wsgi
538 WSGIPassAuthorization On
538 WSGIPassAuthorization On
539
539
540 Apache will by default run as a special Apache user, on Linux systems
540 Apache will by default run as a special Apache user, on Linux systems
541 usually ``www-data`` or ``apache``. If you need to have the repositories
541 usually ``www-data`` or ``apache``. If you need to have the repositories
542 directory owned by a different user, use the user and group options to
542 directory owned by a different user, use the user and group options to
543 WSGIDaemonProcess to set the name of the user and group.
543 WSGIDaemonProcess to set the name of the user and group.
544
544
545 Example WSGI dispatch script:
545 Example WSGI dispatch script:
546
546
547 .. code-block:: python
547 .. code-block:: python
548
548
549 import os
549 import os
550 os.environ['PYTHON_EGG_CACHE'] = '/srv/kallithea/.egg-cache'
550 os.environ['PYTHON_EGG_CACHE'] = '/srv/kallithea/.egg-cache'
551
551
552 # sometimes it's needed to set the current dir
552 # sometimes it's needed to set the current dir
553 os.chdir('/srv/kallithea/')
553 os.chdir('/srv/kallithea/')
554
554
555 import site
555 import site
556 site.addsitedir("/srv/kallithea/venv/lib/python2.7/site-packages")
556 site.addsitedir("/srv/kallithea/venv/lib/python2.7/site-packages")
557
557
558 ini = '/srv/kallithea/my.ini'
558 ini = '/srv/kallithea/my.ini'
559 from paste.script.util.logging_config import fileConfig
559 from paste.script.util.logging_config import fileConfig
560 fileConfig(ini)
560 fileConfig(ini)
561 from paste.deploy import loadapp
561 from paste.deploy import loadapp
562 application = loadapp('config:' + ini)
562 application = loadapp('config:' + ini)
563
563
564 Or using proper virtualenv activation:
564 Or using proper virtualenv activation:
565
565
566 .. code-block:: python
566 .. code-block:: python
567
567
568 activate_this = '/srv/kallithea/venv/bin/activate_this.py'
568 activate_this = '/srv/kallithea/venv/bin/activate_this.py'
569 execfile(activate_this, dict(__file__=activate_this))
569 execfile(activate_this, dict(__file__=activate_this))
570
570
571 import os
571 import os
572 os.environ['HOME'] = '/srv/kallithea'
572 os.environ['HOME'] = '/srv/kallithea'
573
573
574 ini = '/srv/kallithea/kallithea.ini'
574 ini = '/srv/kallithea/kallithea.ini'
575 from paste.script.util.logging_config import fileConfig
575 from paste.script.util.logging_config import fileConfig
576 fileConfig(ini)
576 fileConfig(ini)
577 from paste.deploy import loadapp
577 from paste.deploy import loadapp
578 application = loadapp('config:' + ini)
578 application = loadapp('config:' + ini)
579
579
580
580
581 Other configuration files
581 Other configuration files
582 -------------------------
582 -------------------------
583
583
584 A number of `example init.d scripts`__ can be found in
584 A number of `example init.d scripts`__ can be found in
585 the ``init.d`` directory of the Kallithea source.
585 the ``init.d`` directory of the Kallithea source.
586
586
587 .. __: https://kallithea-scm.org/repos/kallithea/files/tip/init.d/ .
587 .. __: https://kallithea-scm.org/repos/kallithea/files/tip/init.d/ .
588
588
589
589
590 .. _virtualenv: http://pypi.python.org/pypi/virtualenv
590 .. _virtualenv: http://pypi.python.org/pypi/virtualenv
591 .. _python: http://www.python.org/
591 .. _python: http://www.python.org/
592 .. _Python regular expression documentation: https://docs.python.org/2/library/re.html
592 .. _Python regular expression documentation: https://docs.python.org/2/library/re.html
593 .. _Mercurial: https://www.mercurial-scm.org/
593 .. _Mercurial: https://www.mercurial-scm.org/
594 .. _Celery: http://celeryproject.org/
594 .. _Celery: http://celeryproject.org/
595 .. _Celery documentation: http://docs.celeryproject.org/en/latest/getting-started/index.html
595 .. _Celery documentation: http://docs.celeryproject.org/en/latest/getting-started/index.html
596 .. _RabbitMQ: http://www.rabbitmq.com/
596 .. _RabbitMQ: http://www.rabbitmq.com/
597 .. _Redis: http://redis.io/
597 .. _Redis: http://redis.io/
598 .. _mercurial-server: http://www.lshift.net/mercurial-server.html
598 .. _mercurial-server: http://www.lshift.net/mercurial-server.html
599 .. _PublishingRepositories: https://www.mercurial-scm.org/wiki/PublishingRepositories
599 .. _PublishingRepositories: https://www.mercurial-scm.org/wiki/PublishingRepositories
@@ -1,34 +1,34 b''
1 # celeryd - run the celeryd daemon as an upstart job for kallithea
1 # celeryd - run the celeryd daemon as an upstart job for kallithea
2 # Change variables/paths as necessary and place file /etc/init/celeryd.conf
2 # Change variables/paths as necessary and place file /etc/init/celeryd.conf
3 # start/stop/restart as normal upstart job (ie: $ start celeryd)
3 # start/stop/restart as normal upstart job (ie: $ start celeryd)
4
4
5 description "Celery for Kallithea Mercurial Server"
5 description "Celery for Kallithea Mercurial Server"
6 author "Matt Zuba <matt.zuba@goodwillaz.org"
6 author "Matt Zuba <matt.zuba@goodwillaz.org"
7
7
8 start on starting kallithea
8 start on starting kallithea
9 stop on stopped kallithea
9 stop on stopped kallithea
10
10
11 respawn
11 respawn
12
12
13 umask 0022
13 umask 0022
14
14
15 env PIDFILE=/tmp/celeryd.pid
15 env PIDFILE=/tmp/celeryd.pid
16 env APPINI=/var/hg/kallithea/production.ini
16 env APPINI=/var/hg/kallithea/production.ini
17 env HOME=/var/hg
17 env HOME=/var/hg
18 env USER=hg
18 env USER=hg
19 # To use group (if different from user), you must edit sudoers file and change
19 # To use group (if different from user), you must edit sudoers file and change
20 # root's entry from (ALL) to (ALL:ALL)
20 # root's entry from (ALL) to (ALL:ALL)
21 # env GROUP=hg
21 # env GROUP=hg
22
22
23 script
23 script
24 COMMAND="/var/hg/.virtualenvs/kallithea/bin/gearbox celeryd -c $APPINI -- --pidfile=$PIDFILE"
24 COMMAND="/var/hg/.virtualenvs/kallithea/bin/kallithea-cli celery-run -c $APPINI -- --pidfile=$PIDFILE"
25 if [ -z "$GROUP" ]; then
25 if [ -z "$GROUP" ]; then
26 exec sudo -u $USER $COMMAND
26 exec sudo -u $USER $COMMAND
27 else
27 else
28 exec sudo -u $USER -g $GROUP $COMMAND
28 exec sudo -u $USER -g $GROUP $COMMAND
29 fi
29 fi
30 end script
30 end script
31
31
32 post-stop script
32 post-stop script
33 rm -f $PIDFILE
33 rm -f $PIDFILE
34 end script
34 end script
@@ -1,25 +1,26 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 # This program is free software: you can redistribute it and/or modify
2 # This program is free software: you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation, either version 3 of the License, or
4 # the Free Software Foundation, either version 3 of the License, or
5 # (at your option) any later version.
5 # (at your option) any later version.
6 #
6 #
7 # This program is distributed in the hope that it will be useful,
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
10 # GNU General Public License for more details.
11 #
11 #
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 # 'cli' is the main entry point for 'kallithea-cli', specified in setup.py as entry_points console_scripts
15 # 'cli' is the main entry point for 'kallithea-cli', specified in setup.py as entry_points console_scripts
16 from kallithea.bin.kallithea_cli_base import cli
16 from kallithea.bin.kallithea_cli_base import cli
17
17
18 # import commands (they will add themselves to the 'cli' object)
18 # import commands (they will add themselves to the 'cli' object)
19 import kallithea.bin.kallithea_cli_celery
19 import kallithea.bin.kallithea_cli_config
20 import kallithea.bin.kallithea_cli_config
20 import kallithea.bin.kallithea_cli_db
21 import kallithea.bin.kallithea_cli_db
21 import kallithea.bin.kallithea_cli_extensions
22 import kallithea.bin.kallithea_cli_extensions
22 import kallithea.bin.kallithea_cli_iis
23 import kallithea.bin.kallithea_cli_iis
23 import kallithea.bin.kallithea_cli_index
24 import kallithea.bin.kallithea_cli_index
24 import kallithea.bin.kallithea_cli_ishell
25 import kallithea.bin.kallithea_cli_ishell
25 import kallithea.bin.kallithea_cli_repo
26 import kallithea.bin.kallithea_cli_repo
@@ -1,38 +1,39 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 # This program is free software: you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation, either version 3 of the License, or
5 # (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
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/>.
2
14
3 import argparse
15 import click
16 import kallithea.bin.kallithea_cli_base as cli_base
4
17
5 import kallithea
18 import kallithea
6 from kallithea.lib.paster_commands.common import BasePasterCommand
7
8 __all__ = ['Command']
9
10
11 class Command(BasePasterCommand):
12 """Kallithea: Celery worker for asynchronous tasks"""
13
19
14 # Starts the celery worker using configuration from a paste.deploy
20 @cli_base.register_command(config_file_initialize_app=True)
15 # configuration file.
21 @click.argument('celery_args', nargs=-1)
22 def celery_run(celery_args):
23 """Start Celery worker(s) for asynchronous tasks.
16
24
17 def take_action(self, args):
25 This commands starts the Celery daemon which will spawn workers to handle
18 if not kallithea.CELERY_ON:
26 certain asynchronous tasks for Kallithea.
19 raise Exception('Please set use_celery = true in .ini config '
20 'file before running celeryd')
21
27
22 from kallithea.lib import celerypylons
28 Any extra arguments you pass to this command will be passed through to
23 cmd = celerypylons.worker.worker(celerypylons.app)
29 Celery. Use '--' before such extra arguments to avoid options to be parsed
24
30 by this CLI command.
25 celery_args = args.celery_args
31 """
26 if '--' in celery_args:
27 celery_args.remove('--')
28
29 return cmd.run_from_argv('kallithea celery worker', celery_args)
30
32
31 def get_parser(self, prog_name):
33 if not kallithea.CELERY_ON:
32 parser = super(Command, self).get_parser(prog_name)
34 raise Exception('Please set use_celery = true in .ini config '
35 'file before running this command')
33
36
34 parser.add_argument('celery_args', nargs=argparse.REMAINDER,
37 from kallithea.lib import celerypylons
35 help="Pass extra options to Celery after a '--' separator",
38 cmd = celerypylons.worker.worker(celerypylons.app)
36 )
39 return cmd.run_from_argv('kallithea celery worker', celery_args)
37
38 return parser
@@ -1,165 +1,164 b''
1 #!/usr/bin/env python2
1 #!/usr/bin/env python2
2 # -*- coding: utf-8 -*-
2 # -*- coding: utf-8 -*-
3 import os
3 import os
4 import sys
4 import sys
5 import platform
5 import platform
6
6
7 if sys.version_info < (2, 6) or sys.version_info >= (3,):
7 if sys.version_info < (2, 6) or sys.version_info >= (3,):
8 raise Exception('Kallithea requires python 2.6 or 2.7')
8 raise Exception('Kallithea requires python 2.6 or 2.7')
9
9
10
10
11 here = os.path.abspath(os.path.dirname(__file__))
11 here = os.path.abspath(os.path.dirname(__file__))
12
12
13
13
14 def _get_meta_var(name, data, callback_handler=None):
14 def _get_meta_var(name, data, callback_handler=None):
15 import re
15 import re
16 matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data)
16 matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data)
17 if matches:
17 if matches:
18 if not callable(callback_handler):
18 if not callable(callback_handler):
19 callback_handler = lambda v: v
19 callback_handler = lambda v: v
20
20
21 return callback_handler(eval(matches.groups()[0]))
21 return callback_handler(eval(matches.groups()[0]))
22
22
23 _meta = open(os.path.join(here, 'kallithea', '__init__.py'), 'rb')
23 _meta = open(os.path.join(here, 'kallithea', '__init__.py'), 'rb')
24 _metadata = _meta.read()
24 _metadata = _meta.read()
25 _meta.close()
25 _meta.close()
26
26
27 callback = lambda V: ('.'.join(map(str, V[:3])) + '.'.join(V[3:]))
27 callback = lambda V: ('.'.join(map(str, V[:3])) + '.'.join(V[3:]))
28 __version__ = _get_meta_var('VERSION', _metadata, callback)
28 __version__ = _get_meta_var('VERSION', _metadata, callback)
29 __license__ = _get_meta_var('__license__', _metadata)
29 __license__ = _get_meta_var('__license__', _metadata)
30 __author__ = _get_meta_var('__author__', _metadata)
30 __author__ = _get_meta_var('__author__', _metadata)
31 __url__ = _get_meta_var('__url__', _metadata)
31 __url__ = _get_meta_var('__url__', _metadata)
32 # defines current platform
32 # defines current platform
33 __platform__ = platform.system()
33 __platform__ = platform.system()
34
34
35 is_windows = __platform__ in ['Windows']
35 is_windows = __platform__ in ['Windows']
36
36
37 requirements = [
37 requirements = [
38 "alembic >= 0.8.0, < 1.1",
38 "alembic >= 0.8.0, < 1.1",
39 "gearbox < 1",
39 "gearbox < 1",
40 "waitress >= 0.8.8, < 1.2",
40 "waitress >= 0.8.8, < 1.2",
41 "WebOb >= 1.7, < 1.8", # turbogears2 2.3.12 requires WebOb<1.8.0
41 "WebOb >= 1.7, < 1.8", # turbogears2 2.3.12 requires WebOb<1.8.0
42 "backlash >= 0.1.2, < 1",
42 "backlash >= 0.1.2, < 1",
43 "TurboGears2 >= 2.3.10, < 3",
43 "TurboGears2 >= 2.3.10, < 3",
44 "tgext.routes >= 0.2.0, < 1",
44 "tgext.routes >= 0.2.0, < 1",
45 "Beaker >= 1.7.0, < 2",
45 "Beaker >= 1.7.0, < 2",
46 "WebHelpers >= 1.3, < 1.4",
46 "WebHelpers >= 1.3, < 1.4",
47 "FormEncode >= 1.2.4, < 1.4",
47 "FormEncode >= 1.2.4, < 1.4",
48 "SQLAlchemy >= 1.1, < 1.3",
48 "SQLAlchemy >= 1.1, < 1.3",
49 "Mako >= 0.9.0, < 1.1",
49 "Mako >= 0.9.0, < 1.1",
50 "Pygments >= 1.5, < 2.3",
50 "Pygments >= 1.5, < 2.3",
51 "Whoosh >= 2.5.0, < 2.8",
51 "Whoosh >= 2.5.0, < 2.8",
52 "celery >= 3.1, < 4.0", # celery 4 doesn't work
52 "celery >= 3.1, < 4.0", # celery 4 doesn't work
53 "Babel >= 0.9.6, < 2.7",
53 "Babel >= 0.9.6, < 2.7",
54 "python-dateutil >= 1.5.0, < 2.8",
54 "python-dateutil >= 1.5.0, < 2.8",
55 "Markdown >= 2.2.1, < 2.7",
55 "Markdown >= 2.2.1, < 2.7",
56 "docutils >= 0.8.1, < 0.15",
56 "docutils >= 0.8.1, < 0.15",
57 "URLObject >= 2.3.4, < 2.5",
57 "URLObject >= 2.3.4, < 2.5",
58 "Routes >= 1.13, < 2",
58 "Routes >= 1.13, < 2",
59 "dulwich >= 0.14.1, < 0.20",
59 "dulwich >= 0.14.1, < 0.20",
60 "mercurial >= 4.1.1, < 4.9",
60 "mercurial >= 4.1.1, < 4.9",
61 "decorator >= 3.3.2, < 4.4",
61 "decorator >= 3.3.2, < 4.4",
62 "Paste >= 2.0.3, < 3",
62 "Paste >= 2.0.3, < 3",
63 "bleach >= 3.0, < 3.1",
63 "bleach >= 3.0, < 3.1",
64 "Click >= 7.0, < 8",
64 "Click >= 7.0, < 8",
65 ]
65 ]
66
66
67 if sys.version_info < (2, 7):
67 if sys.version_info < (2, 7):
68 requirements.append("importlib == 1.0.1")
68 requirements.append("importlib == 1.0.1")
69 requirements.append("argparse")
69 requirements.append("argparse")
70
70
71 if not is_windows:
71 if not is_windows:
72 requirements.append("bcrypt >= 3.1.0, < 3.2")
72 requirements.append("bcrypt >= 3.1.0, < 3.2")
73
73
74 dependency_links = [
74 dependency_links = [
75 ]
75 ]
76
76
77 classifiers = [
77 classifiers = [
78 'Development Status :: 4 - Beta',
78 'Development Status :: 4 - Beta',
79 'Environment :: Web Environment',
79 'Environment :: Web Environment',
80 'Framework :: Pylons',
80 'Framework :: Pylons',
81 'Intended Audience :: Developers',
81 'Intended Audience :: Developers',
82 'License :: OSI Approved :: GNU General Public License (GPL)',
82 'License :: OSI Approved :: GNU General Public License (GPL)',
83 'Operating System :: OS Independent',
83 'Operating System :: OS Independent',
84 'Programming Language :: Python',
84 'Programming Language :: Python',
85 'Programming Language :: Python :: 2.6',
85 'Programming Language :: Python :: 2.6',
86 'Programming Language :: Python :: 2.7',
86 'Programming Language :: Python :: 2.7',
87 'Topic :: Software Development :: Version Control',
87 'Topic :: Software Development :: Version Control',
88 ]
88 ]
89
89
90
90
91 # additional files from project that goes somewhere in the filesystem
91 # additional files from project that goes somewhere in the filesystem
92 # relative to sys.prefix
92 # relative to sys.prefix
93 data_files = []
93 data_files = []
94
94
95 description = ('Kallithea is a fast and powerful management tool '
95 description = ('Kallithea is a fast and powerful management tool '
96 'for Mercurial and Git with a built in push/pull server, '
96 'for Mercurial and Git with a built in push/pull server, '
97 'full text search and code-review.')
97 'full text search and code-review.')
98
98
99 keywords = ' '.join([
99 keywords = ' '.join([
100 'kallithea', 'mercurial', 'git', 'code review',
100 'kallithea', 'mercurial', 'git', 'code review',
101 'repo groups', 'ldap', 'repository management', 'hgweb replacement',
101 'repo groups', 'ldap', 'repository management', 'hgweb replacement',
102 'hgwebdir', 'gitweb replacement', 'serving hgweb',
102 'hgwebdir', 'gitweb replacement', 'serving hgweb',
103 ])
103 ])
104
104
105 # long description
105 # long description
106 README_FILE = 'README.rst'
106 README_FILE = 'README.rst'
107 try:
107 try:
108 long_description = open(README_FILE).read()
108 long_description = open(README_FILE).read()
109 except IOError as err:
109 except IOError as err:
110 sys.stderr.write(
110 sys.stderr.write(
111 "[WARNING] Cannot find file specified as long_description (%s)\n"
111 "[WARNING] Cannot find file specified as long_description (%s)\n"
112 % README_FILE
112 % README_FILE
113 )
113 )
114 long_description = description
114 long_description = description
115
115
116 import setuptools
116 import setuptools
117
117
118 # monkey patch setuptools to use distutils owner/group functionality
118 # monkey patch setuptools to use distutils owner/group functionality
119 from setuptools.command import sdist
119 from setuptools.command import sdist
120 sdist_org = sdist.sdist
120 sdist_org = sdist.sdist
121 class sdist_new(sdist_org):
121 class sdist_new(sdist_org):
122 def initialize_options(self):
122 def initialize_options(self):
123 sdist_org.initialize_options(self)
123 sdist_org.initialize_options(self)
124 self.owner = self.group = 'root'
124 self.owner = self.group = 'root'
125 sdist.sdist = sdist_new
125 sdist.sdist = sdist_new
126
126
127 packages = setuptools.find_packages(exclude=['ez_setup'])
127 packages = setuptools.find_packages(exclude=['ez_setup'])
128
128
129 setuptools.setup(
129 setuptools.setup(
130 name='Kallithea',
130 name='Kallithea',
131 version=__version__,
131 version=__version__,
132 description=description,
132 description=description,
133 long_description=long_description,
133 long_description=long_description,
134 keywords=keywords,
134 keywords=keywords,
135 license=__license__,
135 license=__license__,
136 author=__author__,
136 author=__author__,
137 author_email='kallithea@sfconservancy.org',
137 author_email='kallithea@sfconservancy.org',
138 dependency_links=dependency_links,
138 dependency_links=dependency_links,
139 url=__url__,
139 url=__url__,
140 install_requires=requirements,
140 install_requires=requirements,
141 classifiers=classifiers,
141 classifiers=classifiers,
142 data_files=data_files,
142 data_files=data_files,
143 packages=packages,
143 packages=packages,
144 include_package_data=True,
144 include_package_data=True,
145 message_extractors={'kallithea': [
145 message_extractors={'kallithea': [
146 ('**.py', 'python', None),
146 ('**.py', 'python', None),
147 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
147 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
148 ('templates/**.html', 'mako', {'input_encoding': 'utf-8'}),
148 ('templates/**.html', 'mako', {'input_encoding': 'utf-8'}),
149 ('public/**', 'ignore', None)]},
149 ('public/**', 'ignore', None)]},
150 zip_safe=False,
150 zip_safe=False,
151 entry_points="""
151 entry_points="""
152 [console_scripts]
152 [console_scripts]
153 kallithea-api = kallithea.bin.kallithea_api:main
153 kallithea-api = kallithea.bin.kallithea_api:main
154 kallithea-gist = kallithea.bin.kallithea_gist:main
154 kallithea-gist = kallithea.bin.kallithea_gist:main
155 kallithea-config = kallithea.bin.kallithea_config:main
155 kallithea-config = kallithea.bin.kallithea_config:main
156 kallithea-cli = kallithea.bin.kallithea_cli:cli
156 kallithea-cli = kallithea.bin.kallithea_cli:cli
157
157
158 [paste.app_factory]
158 [paste.app_factory]
159 main = kallithea.config.middleware:make_app
159 main = kallithea.config.middleware:make_app
160
160
161 [gearbox.commands]
161 [gearbox.commands]
162 celeryd=kallithea.lib.paster_commands.celeryd:Command
163 upgrade-db=kallithea.lib.dbmigrate:UpgradeDb
162 upgrade-db=kallithea.lib.dbmigrate:UpgradeDb
164 """,
163 """,
165 )
164 )
General Comments 0
You need to be logged in to leave comments. Login now