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