Show More
@@ -1,236 +1,236 b'' | |||
|
1 | 1 | .. _overview: |
|
2 | 2 | |
|
3 | 3 | ===================== |
|
4 | 4 | Installation overview |
|
5 | 5 | ===================== |
|
6 | 6 | |
|
7 | 7 | Some overview and some details that can help understanding the options when |
|
8 | 8 | installing Kallithea. |
|
9 | 9 | |
|
10 | 10 | 1. **Prepare environment and external dependencies.** |
|
11 | 11 | Kallithea needs: |
|
12 | 12 | |
|
13 | 13 | * A filesystem where the Mercurial and Git repositories can be stored. |
|
14 | 14 | * A database where meta data can be stored. |
|
15 | 15 | * A Python environment where the Kallithea application and its dependencies |
|
16 | 16 | can be installed. |
|
17 | 17 | * A web server that can host the Kallithea web application using the WSGI |
|
18 | 18 | API. |
|
19 | 19 | |
|
20 | 20 | 2. **Install Kallithea software.** |
|
21 | 21 | This makes the ``kallithea-cli`` command line tool available. |
|
22 | 22 | |
|
23 | 23 | 3. **Create low level configuration file.** |
|
24 | 24 | Use ``kallithea-cli config-create`` to create a ``.ini`` file with database |
|
25 | 25 | connection info, mail server information, configuration for the specified |
|
26 | 26 | web server, etc. |
|
27 | 27 | |
|
28 | 28 | 4. **Populate the database.** |
|
29 | 29 | Use ``kallithea-cli db-create`` with the ``.ini`` file to create the |
|
30 | 30 | database schema and insert the most basic information: the location of the |
|
31 | 31 | repository store and an initial local admin user. |
|
32 | 32 | |
|
33 | 33 | 5. **Prepare front-end files** |
|
34 | 34 | Some front-end files must be fetched or created using ``npm`` tooling so |
|
35 | 35 | they can be served to the client as static files. |
|
36 | 36 | |
|
37 | 37 | 6. **Configure the web server.** |
|
38 | 38 | The web server must invoke the WSGI entrypoint for the Kallithea software |
|
39 | 39 | using the ``.ini`` file (and thus the database). This makes the web |
|
40 | 40 | application available so the local admin user can log in and tweak the |
|
41 | 41 | configuration further. |
|
42 | 42 | |
|
43 | 43 | 7. **Configure users.** |
|
44 | 44 | The initial admin user can create additional local users, or configure how |
|
45 | 45 | users can be created and authenticated from other user directories. |
|
46 | 46 | |
|
47 | 47 | See the subsequent sections, the separate OS-specific instructions, and |
|
48 | 48 | :ref:`setup` for details on these steps. |
|
49 | 49 | |
|
50 | 50 | |
|
51 | 51 | Python environment |
|
52 | 52 | ------------------ |
|
53 | 53 | |
|
54 | 54 | **Kallithea** is written entirely in Python_ and requires Python version |
|
55 | 55 | 3.6 or higher. |
|
56 | 56 | |
|
57 | 57 | Given a Python installation, there are different ways of providing the |
|
58 | 58 | environment for running Python applications. Each of them pretty much |
|
59 | 59 | corresponds to a ``site-packages`` directory somewhere where packages can be |
|
60 | 60 | installed. |
|
61 | 61 | |
|
62 | 62 | Kallithea itself can be run from source or be installed, but even when running |
|
63 | 63 | from source, there are some dependencies that must be installed in the Python |
|
64 | 64 | environment used for running Kallithea. |
|
65 | 65 | |
|
66 | 66 | - Packages *could* be installed in Python's ``site-packages`` directory ... but |
|
67 | 67 | that would require running pip_ as root and it would be hard to uninstall or |
|
68 | 68 | upgrade and is probably not a good idea unless using a package manager. |
|
69 | 69 | |
|
70 | 70 | - Packages could also be installed in ``~/.local`` ... but that is probably |
|
71 | 71 | only a good idea if using a dedicated user per application or instance. |
|
72 | 72 | |
|
73 | 73 | - Finally, it can be installed in a virtualenv. That is a very lightweight |
|
74 | 74 | "container" where each Kallithea instance can get its own dedicated and |
|
75 | 75 | self-contained virtual environment. |
|
76 | 76 | |
|
77 | 77 | We recommend using virtualenv for installing Kallithea. |
|
78 | 78 | |
|
79 | 79 | |
|
80 | 80 | Locale environment |
|
81 | 81 | ------------------ |
|
82 | 82 | |
|
83 | 83 | In order to ensure a correct functioning of Kallithea with respect to non-ASCII |
|
84 | 84 | characters in user names, file paths, commit messages, etc., it is very |
|
85 | 85 | important that Kallithea is run with a correct `locale` configuration. |
|
86 | 86 | |
|
87 | 87 | On Unix, environment variables like ``LANG`` or ``LC_ALL`` can specify a language (like |
|
88 | 88 | ``en_US``) and encoding (like ``UTF-8``) to use for code points outside the ASCII |
|
89 | 89 | range. The flexibility of supporting multiple encodings of Unicode has the flip |
|
90 | 90 | side of having to specify which encoding to use - especially for Mercurial. |
|
91 | 91 | |
|
92 | 92 | It depends on the OS distribution and system configuration which locales are |
|
93 | 93 | available. For example, some Docker containers based on Debian default to only |
|
94 | 94 | supporting the ``C`` language, while other Linux environments have ``en_US`` but not |
|
95 | 95 | ``C``. The ``locale -a`` command will show which values are available on the |
|
96 | 96 | current system. Regardless of the actual language, you should normally choose a |
|
97 | 97 | locale that has the ``UTF-8`` encoding (note that spellings ``utf8``, ``utf-8``, |
|
98 | 98 | ``UTF8``, ``UTF-8`` are all referring to the same thing) |
|
99 | 99 | |
|
100 | 100 | For technical reasons, the locale configuration **must** be provided in the |
|
101 | 101 | environment in which Kallithea runs - it cannot be specified in the ``.ini`` file. |
|
102 | 102 | How to practically do this depends on the web server that is used and the way it |
|
103 | 103 | is started. For example, gearbox is often started by a normal user, either |
|
104 | 104 | manually or via a script. In this case, the required locale environment |
|
105 | 105 | variables can be provided directly in that user's environment or in the script. |
|
106 | 106 | However, web servers like Apache are often started at boot via an init script or |
|
107 | 107 | service file. Modifying the environment for this case would thus require |
|
108 | 108 | root/administrator privileges. Moreover, that environment would dictate the |
|
109 | 109 | settings for all web services running under that web server, Kallithea being |
|
110 | 110 | just one of them. Specifically in the case of Apache with ``mod_wsgi``, the |
|
111 | 111 | locale can be set for a specific service in its ``WSGIDaemonProcess`` directive, |
|
112 | 112 | using the ``lang`` parameter. |
|
113 | 113 | |
|
114 | 114 | |
|
115 | 115 | Installation methods |
|
116 | 116 | -------------------- |
|
117 | 117 | |
|
118 | 118 | Kallithea must be installed on a server. Kallithea is installed in a Python |
|
119 | 119 | environment so it can use packages that are installed there and make itself |
|
120 | 120 | available for other packages. |
|
121 | 121 | |
|
122 | 122 | Two different cases will pretty much cover the options for how it can be |
|
123 | 123 | installed. |
|
124 | 124 | |
|
125 | 125 | - The Kallithea source repository can be cloned and used -- it is kept stable and |
|
126 | 126 | can be used in production. The Kallithea maintainers use the development |
|
127 | 127 | branch in production. The advantage of installation from source and regularly |
|
128 | 128 | updating it is that you take advantage of the most recent improvements. Using |
|
129 | 129 | it directly from a DVCS also means that it is easy to track local customizations. |
|
130 | 130 | |
|
131 | 131 | Running ``pip install -e .`` in the source will use pip to install the |
|
132 | 132 | necessary dependencies in the Python environment and create a |
|
133 | 133 | ``.../site-packages/Kallithea.egg-link`` file there that points at the Kallithea |
|
134 | 134 | source. |
|
135 | 135 | |
|
136 | 136 | - Kallithea can also be installed from ready-made packages using a package manager. |
|
137 | 137 | The official released versions are available on PyPI_ and can be downloaded and |
|
138 | 138 | installed with all dependencies using ``pip install kallithea``. |
|
139 | 139 | |
|
140 | 140 | With this method, Kallithea is installed in the Python environment as any |
|
141 | 141 | other package, usually as a ``.../site-packages/Kallithea-X-py3.8.egg/`` |
|
142 | 142 | directory with Python files and everything else that is needed. |
|
143 | 143 | |
|
144 | 144 | (``pip install kallithea`` from a source tree will do pretty much the same |
|
145 | 145 | but build the Kallithea package itself locally instead of downloading it.) |
|
146 | 146 | |
|
147 | 147 | .. note:: |
|
148 | 148 | Kallithea includes front-end code that needs to be processed to prepare |
|
149 | 149 | static files that can be served at run time and used on the client side. The |
|
150 | 150 | tool npm_ is used to download external dependencies and orchestrate the |
|
151 | 151 | processing. The ``npm`` binary must thus be available at install time but is |
|
152 | 152 | not used at run time. |
|
153 | 153 | |
|
154 | 154 | |
|
155 | 155 | Web server |
|
156 | 156 | ---------- |
|
157 | 157 | |
|
158 | 158 | Kallithea is (primarily) a WSGI_ application that must be run from a web |
|
159 | 159 | server that serves WSGI applications over HTTP. |
|
160 | 160 | |
|
161 | 161 | Kallithea itself is not serving HTTP (or HTTPS); that is the web server's |
|
162 | 162 | responsibility. Kallithea does however need to know its own user facing URL |
|
163 | 163 | (protocol, address, port and path) for each HTTP request. Kallithea will |
|
164 | 164 | usually use its own HTML/cookie based authentication but can also be configured |
|
165 | 165 | to use web server authentication. |
|
166 | 166 | |
|
167 | 167 | There are several web server options: |
|
168 | 168 | |
|
169 | 169 | - Kallithea uses the Gearbox_ tool as command line interface. Gearbox provides |
|
170 | 170 | ``gearbox serve`` as a convenient way to launch a Python WSGI / web server |
|
171 | 171 | from the command line. That is perfect for development and evaluation. |
|
172 | 172 | Actual use in production might have different requirements and need extra |
|
173 | 173 | work to make it manageable as a scalable system service. |
|
174 | 174 | |
|
175 | 175 | Gearbox comes with its own built-in web server for development but Kallithea |
|
176 | 176 | defaults to using Waitress_. Gunicorn_ and Gevent_ are also options. These |
|
177 | 177 | web servers have different limited feature sets. |
|
178 | 178 | |
|
179 | 179 | The web server used by ``gearbox serve`` is configured in the ``.ini`` file. |
|
180 | 180 | Create it with ``config-create`` using for example ``http_server=waitress`` |
|
181 | 181 | to get a configuration starting point for your choice of web server. |
|
182 | 182 | |
|
183 | 183 | (Gearbox will do like ``paste`` and use the WSGI application entry point |
|
184 | 184 | ``kallithea.config.application:make_app`` as specified in ``setup.py``.) |
|
185 | 185 | |
|
186 | 186 | - `Apache httpd`_ can serve WSGI applications directly using mod_wsgi_ and a |
|
187 | 187 | simple Python file with the necessary configuration. This is a good option if |
|
188 | 188 | Apache is an option. |
|
189 | 189 | |
|
190 | 190 | - uWSGI_ is also a full web server with built-in WSGI module. Use |
|
191 | 191 | ``config-create`` with ``http_server=uwsgi`` to get a ``.ini`` file with |
|
192 | 192 | uWSGI configuration. |
|
193 | 193 | |
|
194 | 194 | - IIS_ can also server WSGI applications directly using isapi-wsgi_. |
|
195 | 195 | |
|
196 | 196 | - A `reverse HTTP proxy <https://en.wikipedia.org/wiki/Reverse_proxy>`_ |
|
197 | 197 | can be put in front of another web server which has WSGI support. |
|
198 | 198 | Such a layered setup can be complex but might in some cases be the right |
|
199 | 199 | option, for example to standardize on one internet-facing web server, to add |
|
200 | 200 | encryption or special authentication or for other security reasons, to |
|
201 | 201 | provide caching of static files, or to provide load balancing or fail-over. |
|
202 | 202 | Nginx_, Varnish_ and HAProxy_ are often used for this purpose, often in front |
|
203 | 203 | of a ``gearbox serve`` that somehow is wrapped as a service. |
|
204 | 204 | |
|
205 | 205 | The best option depends on what you are familiar with and the requirements for |
|
206 | 206 | performance and stability. Also, keep in mind that Kallithea mainly is serving |
|
207 | 207 | dynamically generated pages from a relatively slow Python process. Kallithea is |
|
208 | 208 | also often used inside organizations with a limited amount of users and thus no |
|
209 | 209 | continuous hammering from the internet. |
|
210 | 210 | |
|
211 | 211 | .. note:: |
|
212 | 212 | Kallithea, the libraries it uses, and Python itself do in several places use |
|
213 | 213 | simple caching in memory. Caches and memory are not always released in a way |
|
214 | 214 | that is suitable for long-running processes. They might appear to be leaking |
|
215 | 215 | memory. The worker processes should thus regularly be restarted - for |
|
216 | 216 | example after 1000 requests and/or one hour. This can usually be done by the |
|
217 | 217 | web server or the tool used for running it as a system service. |
|
218 | 218 | |
|
219 | 219 | |
|
220 | 220 | .. _Python: http://www.python.org/ |
|
221 | 221 | .. _Gunicorn: http://gunicorn.org/ |
|
222 | 222 | .. _Gevent: http://www.gevent.org/ |
|
223 | .. _Waitress: http://waitress.readthedocs.org/en/latest/ | |
|
224 | .. _Gearbox: http://turbogears.readthedocs.io/en/latest/turbogears/gearbox.html | |
|
223 | .. _Waitress: https://docs.pylonsproject.org/projects/waitress/ | |
|
224 | .. _Gearbox: https://turbogears.readthedocs.io/en/latest/turbogears/gearbox.html | |
|
225 | 225 | .. _PyPI: https://pypi.python.org/pypi |
|
226 | 226 | .. _Apache httpd: http://httpd.apache.org/ |
|
227 | 227 | .. _mod_wsgi: https://code.google.com/p/modwsgi/ |
|
228 | 228 | .. _isapi-wsgi: https://github.com/hexdump42/isapi-wsgi |
|
229 |
.. _uWSGI: https://uwsgi-docs.readthedocs.o |
|
|
229 | .. _uWSGI: https://uwsgi-docs.readthedocs.io/ | |
|
230 | 230 | .. _nginx: http://nginx.org/en/ |
|
231 | 231 | .. _iis: http://en.wikipedia.org/wiki/Internet_Information_Services |
|
232 | 232 | .. _pip: http://en.wikipedia.org/wiki/Pip_%28package_manager%29 |
|
233 | 233 | .. _WSGI: http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface |
|
234 | 234 | .. _HAProxy: http://www.haproxy.org/ |
|
235 | 235 | .. _Varnish: https://www.varnish-cache.org/ |
|
236 | 236 | .. _npm: https://www.npmjs.com/ |
@@ -1,694 +1,694 b'' | |||
|
1 | 1 | .. _setup: |
|
2 | 2 | |
|
3 | 3 | ===== |
|
4 | 4 | Setup |
|
5 | 5 | ===== |
|
6 | 6 | |
|
7 | 7 | |
|
8 | 8 | Setting up Kallithea |
|
9 | 9 | -------------------- |
|
10 | 10 | |
|
11 | 11 | Some further details to the steps mentioned in the overview. |
|
12 | 12 | |
|
13 | 13 | Create low level configuration file |
|
14 | 14 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
15 | 15 | |
|
16 | 16 | First, you will need to create a Kallithea configuration file. The |
|
17 | 17 | configuration file is a ``.ini`` file that contains various low level settings |
|
18 | 18 | for Kallithea, e.g. configuration of how to use database, web server, email, |
|
19 | 19 | and logging. |
|
20 | 20 | |
|
21 | 21 | Run the following command to create the file ``my.ini`` in the current |
|
22 | 22 | directory:: |
|
23 | 23 | |
|
24 | 24 | kallithea-cli config-create my.ini http_server=waitress |
|
25 | 25 | |
|
26 | 26 | To get a good starting point for your configuration, specify the http server |
|
27 | 27 | you intend to use. It can be ``waitress``, ``gearbox``, ``gevent``, |
|
28 | 28 | ``gunicorn``, or ``uwsgi``. (Apache ``mod_wsgi`` will not use this |
|
29 | 29 | configuration file, and it is fine to keep the default http_server configuration |
|
30 | 30 | unused. ``mod_wsgi`` is configured using ``httpd.conf`` directives and a WSGI |
|
31 | 31 | wrapper script.) |
|
32 | 32 | |
|
33 | 33 | Extra custom settings can be specified like:: |
|
34 | 34 | |
|
35 | 35 | kallithea-cli config-create my.ini host=8.8.8.8 "[handler_console]" formatter=color_formatter |
|
36 | 36 | |
|
37 | 37 | Populate the database |
|
38 | 38 | ^^^^^^^^^^^^^^^^^^^^^ |
|
39 | 39 | |
|
40 | 40 | Next, you need to create the databases used by Kallithea. Kallithea currently |
|
41 | 41 | supports PostgreSQL, SQLite and MariaDB/MySQL databases. It is recommended to |
|
42 | 42 | start out using SQLite (the default) and move to PostgreSQL if it becomes a |
|
43 | 43 | bottleneck or to get a "proper" database. MariaDB/MySQL is also supported. |
|
44 | 44 | |
|
45 | 45 | For PostgreSQL, run ``pip install psycopg2`` to get the database driver. Make |
|
46 | 46 | sure the PostgreSQL server is initialized and running. Make sure you have a |
|
47 | 47 | database user with password authentication with permissions to create databases |
|
48 | 48 | - for example by running:: |
|
49 | 49 | |
|
50 | 50 | sudo -u postgres createuser 'kallithea' --pwprompt --createdb |
|
51 | 51 | |
|
52 | 52 | For MariaDB/MySQL, run ``pip install mysqlclient`` to get the ``MySQLdb`` |
|
53 | 53 | database driver. Make sure the database server is initialized and running. Make |
|
54 | 54 | sure you have a database user with password authentication with permissions to |
|
55 | 55 | create the database - for example by running:: |
|
56 | 56 | |
|
57 | 57 | echo 'CREATE USER "kallithea"@"localhost" IDENTIFIED BY "password"' | sudo -u mysql mysql |
|
58 | 58 | echo 'GRANT ALL PRIVILEGES ON `kallithea`.* TO "kallithea"@"localhost"' | sudo -u mysql mysql |
|
59 | 59 | |
|
60 | 60 | Check and adjust ``sqlalchemy.url`` in your ``my.ini`` configuration file to use |
|
61 | 61 | this database. |
|
62 | 62 | |
|
63 | 63 | Create the database, tables, and initial content by running the following |
|
64 | 64 | command:: |
|
65 | 65 | |
|
66 | 66 | kallithea-cli db-create -c my.ini |
|
67 | 67 | |
|
68 | 68 | This will first prompt you for a "root" path. This "root" path is the location |
|
69 | 69 | where Kallithea will store all of its repositories on the current machine. This |
|
70 | 70 | location must be writable for the running Kallithea application. Next, |
|
71 | 71 | ``db-create`` will prompt you for a username and password for the initial admin |
|
72 | 72 | account it sets up for you. |
|
73 | 73 | |
|
74 | 74 | The ``db-create`` values can also be given on the command line. |
|
75 | 75 | Example:: |
|
76 | 76 | |
|
77 | 77 | kallithea-cli db-create -c my.ini --user=nn --password=secret --email=nn@example.com --repos=/srv/repos |
|
78 | 78 | |
|
79 | 79 | The ``db-create`` command will create all needed tables and an |
|
80 | 80 | admin account. When choosing a root path you can either use a new |
|
81 | 81 | empty location, or a location which already contains existing |
|
82 | 82 | repositories. If you choose a location which contains existing |
|
83 | 83 | repositories Kallithea will add all of the repositories at the chosen |
|
84 | 84 | location to its database. (Note: make sure you specify the correct |
|
85 | 85 | path to the root). |
|
86 | 86 | |
|
87 | 87 | .. note:: It is also possible to use an existing database. For example, |
|
88 | 88 | when using PostgreSQL without granting general createdb privileges to |
|
89 | 89 | the PostgreSQL kallithea user, set ``sqlalchemy.url = |
|
90 | 90 | postgresql://kallithea:password@localhost/kallithea`` and create the |
|
91 | 91 | database like:: |
|
92 | 92 | |
|
93 | 93 | sudo -u postgres createdb 'kallithea' --owner 'kallithea' |
|
94 | 94 | kallithea-cli db-create -c my.ini --reuse |
|
95 | 95 | |
|
96 | 96 | Prepare front-end files |
|
97 | 97 | ^^^^^^^^^^^^^^^^^^^^^^^ |
|
98 | 98 | |
|
99 | 99 | Finally, the front-end files must be prepared. This requires ``npm`` version 6 |
|
100 | 100 | or later, which needs ``node.js`` (version 12 or later). Prepare the front-end |
|
101 | 101 | by running:: |
|
102 | 102 | |
|
103 | 103 | kallithea-cli front-end-build |
|
104 | 104 | |
|
105 | 105 | Running |
|
106 | 106 | ^^^^^^^ |
|
107 | 107 | |
|
108 | 108 | You are now ready to use Kallithea. To run it using a gearbox web server, |
|
109 | 109 | simply execute:: |
|
110 | 110 | |
|
111 | 111 | gearbox serve -c my.ini |
|
112 | 112 | |
|
113 | 113 | - This command runs the Kallithea server. The web app should be available at |
|
114 | 114 | http://127.0.0.1:5000. The IP address and port is configurable via the |
|
115 | 115 | configuration file created in the previous step. |
|
116 | 116 | - Log in to Kallithea using the admin account created when running ``db-create``. |
|
117 | 117 | - The default permissions on each repository is read, and the owner is admin. |
|
118 | 118 | Remember to update these if needed. |
|
119 | 119 | - In the admin panel you can toggle LDAP, anonymous, and permissions |
|
120 | 120 | settings, as well as edit more advanced options on users and |
|
121 | 121 | repositories. |
|
122 | 122 | |
|
123 | 123 | |
|
124 | 124 | Internationalization (i18n support) |
|
125 | 125 | ----------------------------------- |
|
126 | 126 | |
|
127 | 127 | The Kallithea web interface is automatically displayed in the user's preferred |
|
128 | 128 | language, as indicated by the browser. Thus, different users may see the |
|
129 | 129 | application in different languages. If the requested language is not available |
|
130 | 130 | (because the translation file for that language does not yet exist or is |
|
131 | 131 | incomplete), English is used. |
|
132 | 132 | |
|
133 | 133 | If you want to disable automatic language detection and instead configure a |
|
134 | 134 | fixed language regardless of user preference, set ``i18n.enabled = false`` and |
|
135 | 135 | specify another language by setting ``i18n.lang`` in the Kallithea |
|
136 | 136 | configuration file. |
|
137 | 137 | |
|
138 | 138 | |
|
139 | 139 | Using Kallithea with SSH |
|
140 | 140 | ------------------------ |
|
141 | 141 | |
|
142 | 142 | Kallithea supports repository access via SSH key based authentication. |
|
143 | 143 | This means: |
|
144 | 144 | |
|
145 | 145 | - repository URLs like ``ssh://kallithea@example.com/name/of/repository`` |
|
146 | 146 | |
|
147 | 147 | - all network traffic for both read and write happens over the SSH protocol on |
|
148 | 148 | port 22, without using HTTP/HTTPS nor the Kallithea WSGI application |
|
149 | 149 | |
|
150 | 150 | - encryption and authentication protocols are managed by the system's ``sshd`` |
|
151 | 151 | process, with all users using the same Kallithea system user (e.g. |
|
152 | 152 | ``kallithea``) when connecting to the SSH server, but with users' public keys |
|
153 | 153 | in the Kallithea system user's `.ssh/authorized_keys` file granting each user |
|
154 | 154 | sandboxed access to the repositories. |
|
155 | 155 | |
|
156 | 156 | - users and admins can manage SSH public keys in the web UI |
|
157 | 157 | |
|
158 | 158 | - in their SSH client configuration, users can configure how the client should |
|
159 | 159 | control access to their SSH key - without passphrase, with passphrase, and |
|
160 | 160 | optionally with passphrase caching in the local shell session (``ssh-agent``). |
|
161 | 161 | This is standard SSH functionality, not something Kallithea provides or |
|
162 | 162 | interferes with. |
|
163 | 163 | |
|
164 | 164 | - network communication between client and server happens in a bidirectional |
|
165 | 165 | stateful stream, and will in some cases be faster than HTTP/HTTPS with several |
|
166 | 166 | stateless round-trips. |
|
167 | 167 | |
|
168 | 168 | .. note:: At this moment, repository access via SSH has been tested on Unix |
|
169 | 169 | only. Windows users that care about SSH are invited to test it and report |
|
170 | 170 | problems, ideally contributing patches that solve these problems. |
|
171 | 171 | |
|
172 | 172 | Users and admins can upload SSH public keys (e.g. ``.ssh/id_rsa.pub``) through |
|
173 | 173 | the web interface. The server's ``.ssh/authorized_keys`` file is automatically |
|
174 | 174 | maintained with an entry for each SSH key. Each entry will tell ``sshd`` to run |
|
175 | 175 | ``kallithea-cli`` with the ``ssh-serve`` sub-command and the right Kallithea user ID |
|
176 | 176 | when encountering the corresponding SSH key. |
|
177 | 177 | |
|
178 | 178 | To enable SSH repository access, Kallithea must be configured with the path to |
|
179 | 179 | the ``.ssh/authorized_keys`` file for the Kallithea user, and the path to the |
|
180 | 180 | ``kallithea-cli`` command. Put something like this in the ``.ini`` file:: |
|
181 | 181 | |
|
182 | 182 | ssh_enabled = true |
|
183 | 183 | ssh_authorized_keys = /home/kallithea/.ssh/authorized_keys |
|
184 | 184 | kallithea_cli_path = /srv/kallithea/venv/bin/kallithea-cli |
|
185 | 185 | |
|
186 | 186 | The SSH service must be running, and the Kallithea user account must be active |
|
187 | 187 | (not necessarily with password access, but public key access must be enabled), |
|
188 | 188 | all file permissions must be set as sshd wants it, and ``authorized_keys`` must |
|
189 | 189 | be writeable by the Kallithea user. |
|
190 | 190 | |
|
191 | 191 | .. note:: The ``authorized_keys`` file will be rewritten from scratch on |
|
192 | 192 | each update. If it already exists with other data, Kallithea will not |
|
193 | 193 | overwrite the existing ``authorized_keys``, and the server process will |
|
194 | 194 | instead throw an exception. The system administrator thus cannot ssh |
|
195 | 195 | directly to the Kallithea user but must use su/sudo from another account. |
|
196 | 196 | |
|
197 | 197 | If ``/home/kallithea/.ssh/`` (the directory of the path specified in the |
|
198 | 198 | ``ssh_authorized_keys`` setting of the ``.ini`` file) does not exist as a |
|
199 | 199 | directory, Kallithea will attempt to create it. If that path exists but is |
|
200 | 200 | *not* a directory, or is not readable-writable-executable by the server |
|
201 | 201 | process, the server process will raise an exception each time it attempts to |
|
202 | 202 | write the ``authorized_keys`` file. |
|
203 | 203 | |
|
204 | 204 | .. note:: It is possible to configure the SSH server to look for authorized |
|
205 | 205 | keys in multiple files, for example reserving ``ssh/authorized_keys`` to be |
|
206 | 206 | used for normal SSH and with Kallithea using |
|
207 | 207 | ``.ssh/authorized_keys_kallithea``. In ``/etc/ssh/sshd_config`` set |
|
208 | 208 | ``AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys_kallithea`` |
|
209 | 209 | and restart sshd, and in ``my.ini`` set ``ssh_authorized_keys = |
|
210 | 210 | /home/kallithea/.ssh/authorized_keys_kallithea``. Note that this new |
|
211 | 211 | location will apply to all system users, and that multiple entries for the |
|
212 | 212 | same SSH key will shadow each other. |
|
213 | 213 | |
|
214 | 214 | .. warning:: The handling of SSH access is steered directly by the command |
|
215 | 215 | specified in the ``authorized_keys`` file. There is no interaction with the |
|
216 | 216 | web UI. Once SSH access is correctly configured and enabled, it will work |
|
217 | 217 | regardless of whether the Kallithea web process is actually running. Hence, |
|
218 | 218 | if you want to perform repository or server maintenance and want to fully |
|
219 | 219 | disable all access to the repositories, disable SSH access by setting |
|
220 | 220 | ``ssh_enabled = false`` in the correct ``.ini`` file (i.e. the ``.ini`` file |
|
221 | 221 | specified in the ``authorized_keys`` file.) |
|
222 | 222 | |
|
223 | 223 | The ``authorized_keys`` file can be updated manually with ``kallithea-cli |
|
224 | 224 | ssh-update-authorized-keys -c my.ini``. This command is not needed in normal |
|
225 | 225 | operation but is for example useful after changing SSH-related settings in the |
|
226 | 226 | ``.ini`` file or renaming that file. (The path to the ``.ini`` file is used in |
|
227 | 227 | the generated ``authorized_keys`` file). |
|
228 | 228 | |
|
229 | 229 | |
|
230 | 230 | Setting up Whoosh full text search |
|
231 | 231 | ---------------------------------- |
|
232 | 232 | |
|
233 | 233 | Kallithea provides full text search of repositories using `Whoosh`__. |
|
234 | 234 | |
|
235 |
.. __: https://whoosh.readthedocs.io/ |
|
|
235 | .. __: https://whoosh.readthedocs.io/ | |
|
236 | 236 | |
|
237 | 237 | For an incremental index build, run:: |
|
238 | 238 | |
|
239 | 239 | kallithea-cli index-create -c my.ini |
|
240 | 240 | |
|
241 | 241 | For a full index rebuild, run:: |
|
242 | 242 | |
|
243 | 243 | kallithea-cli index-create -c my.ini --full |
|
244 | 244 | |
|
245 | 245 | The ``--repo-location`` option allows the location of the repositories to be overridden; |
|
246 | 246 | usually, the location is retrieved from the Kallithea database. |
|
247 | 247 | |
|
248 | 248 | The ``--index-only`` option can be used to limit the indexed repositories to a comma-separated list:: |
|
249 | 249 | |
|
250 | 250 | kallithea-cli index-create -c my.ini --index-only=vcs,kallithea |
|
251 | 251 | |
|
252 | 252 | To keep your index up-to-date it is necessary to do periodic index builds; |
|
253 | 253 | for this, it is recommended to use a crontab entry. Example:: |
|
254 | 254 | |
|
255 | 255 | 0 3 * * * /path/to/virtualenv/bin/kallithea-cli index-create -c /path/to/kallithea/my.ini |
|
256 | 256 | |
|
257 | 257 | When using incremental mode (the default), Whoosh will check the last |
|
258 | 258 | modification date of each file and add it to be reindexed if a newer file is |
|
259 | 259 | available. The indexing daemon checks for any removed files and removes them |
|
260 | 260 | from index. |
|
261 | 261 | |
|
262 | 262 | If you want to rebuild the index from scratch, you can use the ``-f`` flag as above, |
|
263 | 263 | or in the admin panel you can check the "build from scratch" checkbox. |
|
264 | 264 | |
|
265 | 265 | |
|
266 | 266 | Integration with issue trackers |
|
267 | 267 | ------------------------------- |
|
268 | 268 | |
|
269 | 269 | Kallithea provides a simple integration with issue trackers. It's possible |
|
270 | 270 | to define a regular expression that will match an issue ID in commit messages, |
|
271 | 271 | and have that replaced with a URL to the issue. |
|
272 | 272 | |
|
273 | 273 | This is achieved with following three variables in the ini file:: |
|
274 | 274 | |
|
275 | 275 | issue_pat = #(\d+) |
|
276 | 276 | issue_server_link = https://issues.example.com/{repo}/issue/\1 |
|
277 | 277 | issue_sub = |
|
278 | 278 | |
|
279 | 279 | ``issue_pat`` is the regular expression describing which strings in |
|
280 | 280 | commit messages will be treated as issue references. The expression can/should |
|
281 | 281 | have one or more parenthesized groups that can later be referred to in |
|
282 | 282 | ``issue_server_link`` and ``issue_sub`` (see below). If you prefer, named groups |
|
283 | 283 | can be used instead of simple parenthesized groups. |
|
284 | 284 | |
|
285 | 285 | If the pattern should only match if it is preceded by whitespace, add the |
|
286 | 286 | following string before the actual pattern: ``(?:^|(?<=\s))``. |
|
287 | 287 | If the pattern should only match if it is followed by whitespace, add the |
|
288 | 288 | following string after the actual pattern: ``(?:$|(?=\s))``. |
|
289 | 289 | These expressions use lookbehind and lookahead assertions of the Python regular |
|
290 | 290 | expression module to avoid the whitespace to be part of the actual pattern, |
|
291 | 291 | otherwise the link text will also contain that whitespace. |
|
292 | 292 | |
|
293 | 293 | Matched issue references are replaced with the link specified in |
|
294 | 294 | ``issue_server_link``, in which any backreferences are resolved. Backreferences |
|
295 | 295 | can be ``\1``, ``\2``, ... or for named groups ``\g<groupname>``. |
|
296 | 296 | The special token ``{repo}`` is replaced with the full repository path |
|
297 | 297 | (including repository groups), while token ``{repo_name}`` is replaced with the |
|
298 | 298 | repository name (without repository groups). |
|
299 | 299 | |
|
300 | 300 | The link text is determined by ``issue_sub``, which can be a string containing |
|
301 | 301 | backreferences to the groups specified in ``issue_pat``. If ``issue_sub`` is |
|
302 | 302 | empty, then the text matched by ``issue_pat`` is used verbatim. |
|
303 | 303 | |
|
304 | 304 | The example settings shown above match issues in the format ``#<number>``. |
|
305 | 305 | This will cause the text ``#300`` to be transformed into a link: |
|
306 | 306 | |
|
307 | 307 | .. code-block:: html |
|
308 | 308 | |
|
309 | 309 | <a href="https://issues.example.com/example_repo/issue/300">#300</a> |
|
310 | 310 | |
|
311 | 311 | The following example transforms a text starting with either of 'pullrequest', |
|
312 | 312 | 'pull request' or 'PR', followed by an optional space, then a pound character |
|
313 | 313 | (#) and one or more digits, into a link with the text 'PR #' followed by the |
|
314 | 314 | digits:: |
|
315 | 315 | |
|
316 | 316 | issue_pat = (pullrequest|pull request|PR) ?#(\d+) |
|
317 | 317 | issue_server_link = https://issues.example.com/\2 |
|
318 | 318 | issue_sub = PR #\2 |
|
319 | 319 | |
|
320 | 320 | The following example demonstrates how to require whitespace before the issue |
|
321 | 321 | reference in order for it to be recognized, such that the text ``issue#123`` will |
|
322 | 322 | not cause a match, but ``issue #123`` will:: |
|
323 | 323 | |
|
324 | 324 | issue_pat = (?:^|(?<=\s))#(\d+) |
|
325 | 325 | issue_server_link = https://issues.example.com/\1 |
|
326 | 326 | issue_sub = |
|
327 | 327 | |
|
328 | 328 | If needed, more than one pattern can be specified by appending a unique suffix to |
|
329 | 329 | the variables. For example, also demonstrating the use of named groups:: |
|
330 | 330 | |
|
331 | 331 | issue_pat_wiki = wiki-(?P<pagename>\S+) |
|
332 | 332 | issue_server_link_wiki = https://wiki.example.com/\g<pagename> |
|
333 | 333 | issue_sub_wiki = WIKI-\g<pagename> |
|
334 | 334 | |
|
335 | 335 | With these settings, wiki pages can be referenced as wiki-some-id, and every |
|
336 | 336 | such reference will be transformed into: |
|
337 | 337 | |
|
338 | 338 | .. code-block:: html |
|
339 | 339 | |
|
340 | 340 | <a href="https://wiki.example.com/some-id">WIKI-some-id</a> |
|
341 | 341 | |
|
342 | 342 | Refer to the `Python regular expression documentation`_ for more details about |
|
343 | 343 | the supported syntax in ``issue_pat``, ``issue_server_link`` and ``issue_sub``. |
|
344 | 344 | |
|
345 | 345 | |
|
346 | 346 | Hook management |
|
347 | 347 | --------------- |
|
348 | 348 | |
|
349 | 349 | Hooks can be managed in similar way to that used in ``.hgrc`` files. |
|
350 | 350 | To manage hooks, choose *Admin > Settings > Hooks*. |
|
351 | 351 | |
|
352 | 352 | The built-in hooks cannot be modified, though they can be enabled or disabled in the *VCS* section. |
|
353 | 353 | |
|
354 | 354 | To add another custom hook simply fill in the first textbox with |
|
355 | 355 | ``<name>.<hook_type>`` and the second with the hook path. Example hooks |
|
356 | 356 | can be found in ``kallithea.lib.hooks``. |
|
357 | 357 | |
|
358 | 358 | |
|
359 | 359 | Changing default encoding |
|
360 | 360 | ------------------------- |
|
361 | 361 | |
|
362 | 362 | By default, Kallithea uses UTF-8 encoding. |
|
363 | 363 | This is configurable as ``default_encoding`` in the .ini file. |
|
364 | 364 | This affects many parts in Kallithea including user names, filenames, and |
|
365 | 365 | encoding of commit messages. In addition Kallithea can detect if the ``chardet`` |
|
366 | 366 | library is installed. If ``chardet`` is detected Kallithea will fallback to it |
|
367 | 367 | when there are encode/decode errors. |
|
368 | 368 | |
|
369 | 369 | The Mercurial encoding is configurable as ``hgencoding``. It is similar to |
|
370 | 370 | setting the ``HGENCODING`` environment variable, but will override it. |
|
371 | 371 | |
|
372 | 372 | |
|
373 | 373 | Celery configuration |
|
374 | 374 | -------------------- |
|
375 | 375 | |
|
376 | 376 | Kallithea can use the distributed task queue system Celery_ to run tasks like |
|
377 | 377 | cloning repositories or sending emails. |
|
378 | 378 | |
|
379 | 379 | Kallithea will in most setups work perfectly fine out of the box (without |
|
380 | 380 | Celery), executing all tasks in the web server process. Some tasks can however |
|
381 | 381 | take some time to run and it can be better to run such tasks asynchronously in |
|
382 | 382 | a separate process so the web server can focus on serving web requests. |
|
383 | 383 | |
|
384 | 384 | For installation and configuration of Celery, see the `Celery documentation`_. |
|
385 | 385 | Note that Celery requires a message broker service like RabbitMQ_ (recommended) |
|
386 | 386 | or Redis_. |
|
387 | 387 | |
|
388 | 388 | The use of Celery is configured in the Kallithea ini configuration file. |
|
389 | 389 | To enable it, simply set:: |
|
390 | 390 | |
|
391 | 391 | use_celery = true |
|
392 | 392 | |
|
393 | 393 | and add or change the ``celery.*`` configuration variables. |
|
394 | 394 | |
|
395 | 395 | Configuration settings are prefixed with 'celery.', so for example setting |
|
396 | 396 | `broker_url` in Celery means setting `celery.broker_url` in the configuration |
|
397 | 397 | file. |
|
398 | 398 | |
|
399 | 399 | To start the Celery process, run:: |
|
400 | 400 | |
|
401 | 401 | kallithea-cli celery-run -c my.ini |
|
402 | 402 | |
|
403 | 403 | Extra options to the Celery worker can be passed after ``--`` - see ``-- -h`` |
|
404 | 404 | for more info. |
|
405 | 405 | |
|
406 | 406 | .. note:: |
|
407 | 407 | Make sure you run this command from the same virtualenv, and with the same |
|
408 | 408 | user that Kallithea runs. |
|
409 | 409 | |
|
410 | 410 | |
|
411 | 411 | HTTPS support |
|
412 | 412 | ------------- |
|
413 | 413 | |
|
414 | 414 | Kallithea will by default generate URLs based on the WSGI environment. |
|
415 | 415 | |
|
416 | 416 | Alternatively, you can use some special configuration settings to control |
|
417 | 417 | directly which scheme/protocol Kallithea will use when generating URLs: |
|
418 | 418 | |
|
419 | 419 | - With ``https_fixup = true``, the scheme will be taken from the |
|
420 | 420 | ``X-Url-Scheme``, ``X-Forwarded-Scheme`` or ``X-Forwarded-Proto`` HTTP header |
|
421 | 421 | (default ``http``). |
|
422 | 422 | - With ``force_https = true`` the default will be ``https``. |
|
423 | 423 | - With ``use_htsts = true``, Kallithea will set ``Strict-Transport-Security`` when using https. |
|
424 | 424 | |
|
425 | 425 | .. _nginx_virtual_host: |
|
426 | 426 | |
|
427 | 427 | |
|
428 | 428 | Nginx virtual host example |
|
429 | 429 | -------------------------- |
|
430 | 430 | |
|
431 | 431 | Sample config for Nginx using proxy: |
|
432 | 432 | |
|
433 | 433 | .. code-block:: nginx |
|
434 | 434 | |
|
435 | 435 | upstream kallithea { |
|
436 | 436 | server 127.0.0.1:5000; |
|
437 | 437 | # add more instances for load balancing |
|
438 | 438 | #server 127.0.0.1:5001; |
|
439 | 439 | #server 127.0.0.1:5002; |
|
440 | 440 | } |
|
441 | 441 | |
|
442 | 442 | ## gist alias |
|
443 | 443 | server { |
|
444 | 444 | listen 443; |
|
445 | 445 | server_name gist.example.com; |
|
446 | 446 | access_log /var/log/nginx/gist.access.log; |
|
447 | 447 | error_log /var/log/nginx/gist.error.log; |
|
448 | 448 | |
|
449 | 449 | ssl on; |
|
450 | 450 | ssl_certificate gist.your.kallithea.server.crt; |
|
451 | 451 | ssl_certificate_key gist.your.kallithea.server.key; |
|
452 | 452 | |
|
453 | 453 | ssl_session_timeout 5m; |
|
454 | 454 | |
|
455 | 455 | ssl_protocols SSLv3 TLSv1; |
|
456 | 456 | 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; |
|
457 | 457 | ssl_prefer_server_ciphers on; |
|
458 | 458 | |
|
459 | 459 | rewrite ^/(.+)$ https://kallithea.example.com/_admin/gists/$1; |
|
460 | 460 | rewrite (.*) https://kallithea.example.com/_admin/gists; |
|
461 | 461 | } |
|
462 | 462 | |
|
463 | 463 | server { |
|
464 | 464 | listen 443; |
|
465 | 465 | server_name kallithea.example.com |
|
466 | 466 | access_log /var/log/nginx/kallithea.access.log; |
|
467 | 467 | error_log /var/log/nginx/kallithea.error.log; |
|
468 | 468 | |
|
469 | 469 | ssl on; |
|
470 | 470 | ssl_certificate your.kallithea.server.crt; |
|
471 | 471 | ssl_certificate_key your.kallithea.server.key; |
|
472 | 472 | |
|
473 | 473 | ssl_session_timeout 5m; |
|
474 | 474 | |
|
475 | 475 | ssl_protocols SSLv3 TLSv1; |
|
476 | 476 | 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; |
|
477 | 477 | ssl_prefer_server_ciphers on; |
|
478 | 478 | |
|
479 | 479 | ## uncomment root directive if you want to serve static files by nginx |
|
480 | 480 | ## requires static_files = false in .ini file |
|
481 | 481 | #root /srv/kallithea/kallithea/kallithea/public; |
|
482 | 482 | include /etc/nginx/proxy.conf; |
|
483 | 483 | location / { |
|
484 | 484 | try_files $uri @kallithea; |
|
485 | 485 | } |
|
486 | 486 | |
|
487 | 487 | location @kallithea { |
|
488 | 488 | proxy_pass http://127.0.0.1:5000; |
|
489 | 489 | } |
|
490 | 490 | |
|
491 | 491 | } |
|
492 | 492 | |
|
493 | 493 | Here's the proxy.conf. It's tuned so it will not timeout on long |
|
494 | 494 | pushes or large pushes:: |
|
495 | 495 | |
|
496 | 496 | proxy_redirect off; |
|
497 | 497 | proxy_set_header Host $host; |
|
498 | 498 | ## needed for container auth |
|
499 | 499 | #proxy_set_header REMOTE_USER $remote_user; |
|
500 | 500 | #proxy_set_header X-Forwarded-User $remote_user; |
|
501 | 501 | proxy_set_header X-Url-Scheme $scheme; |
|
502 | 502 | proxy_set_header X-Host $http_host; |
|
503 | 503 | proxy_set_header X-Real-IP $remote_addr; |
|
504 | 504 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
505 | 505 | proxy_set_header Proxy-host $proxy_host; |
|
506 | 506 | proxy_buffering off; |
|
507 | 507 | proxy_connect_timeout 7200; |
|
508 | 508 | proxy_send_timeout 7200; |
|
509 | 509 | proxy_read_timeout 7200; |
|
510 | 510 | proxy_buffers 8 32k; |
|
511 | 511 | client_max_body_size 1024m; |
|
512 | 512 | client_body_buffer_size 128k; |
|
513 | 513 | large_client_header_buffers 8 64k; |
|
514 | 514 | |
|
515 | 515 | .. _apache_virtual_host_reverse_proxy: |
|
516 | 516 | |
|
517 | 517 | |
|
518 | 518 | Apache virtual host reverse proxy example |
|
519 | 519 | ----------------------------------------- |
|
520 | 520 | |
|
521 | 521 | Here is a sample configuration file for Apache using proxy: |
|
522 | 522 | |
|
523 | 523 | .. code-block:: apache |
|
524 | 524 | |
|
525 | 525 | <VirtualHost *:80> |
|
526 | 526 | ServerName kallithea.example.com |
|
527 | 527 | |
|
528 | 528 | <Proxy *> |
|
529 | 529 | # For Apache 2.4 and later: |
|
530 | 530 | Require all granted |
|
531 | 531 | |
|
532 | 532 | # For Apache 2.2 and earlier, instead use: |
|
533 | 533 | # Order allow,deny |
|
534 | 534 | # Allow from all |
|
535 | 535 | </Proxy> |
|
536 | 536 | |
|
537 | 537 | #important ! |
|
538 | 538 | #Directive to properly generate url (clone url) for Kallithea |
|
539 | 539 | ProxyPreserveHost On |
|
540 | 540 | |
|
541 | 541 | #kallithea instance |
|
542 | 542 | ProxyPass / http://127.0.0.1:5000/ |
|
543 | 543 | ProxyPassReverse / http://127.0.0.1:5000/ |
|
544 | 544 | |
|
545 | 545 | #to enable https use line below |
|
546 | 546 | #SetEnvIf X-Url-Scheme https HTTPS=1 |
|
547 | 547 | </VirtualHost> |
|
548 | 548 | |
|
549 | 549 | Additional tutorial |
|
550 | 550 | http://pylonsbook.com/en/1.1/deployment.html#using-apache-to-proxy-requests-to-pylons |
|
551 | 551 | |
|
552 | 552 | .. _apache_subdirectory: |
|
553 | 553 | |
|
554 | 554 | |
|
555 | 555 | Apache as subdirectory |
|
556 | 556 | ---------------------- |
|
557 | 557 | |
|
558 | 558 | Apache subdirectory part: |
|
559 | 559 | |
|
560 | 560 | .. code-block:: apache |
|
561 | 561 | |
|
562 | 562 | <Location /PREFIX > |
|
563 | 563 | ProxyPass http://127.0.0.1:5000/PREFIX |
|
564 | 564 | ProxyPassReverse http://127.0.0.1:5000/PREFIX |
|
565 | 565 | SetEnvIf X-Url-Scheme https HTTPS=1 |
|
566 | 566 | </Location> |
|
567 | 567 | |
|
568 | 568 | Besides the regular apache setup you will need to add the following line |
|
569 | 569 | into ``[app:main]`` section of your .ini file:: |
|
570 | 570 | |
|
571 | 571 | filter-with = proxy-prefix |
|
572 | 572 | |
|
573 | 573 | Add the following at the end of the .ini file:: |
|
574 | 574 | |
|
575 | 575 | [filter:proxy-prefix] |
|
576 | 576 | use = egg:PasteDeploy#prefix |
|
577 | 577 | prefix = /PREFIX |
|
578 | 578 | |
|
579 | 579 | then change ``PREFIX`` into your chosen prefix |
|
580 | 580 | |
|
581 | 581 | .. _apache_mod_wsgi: |
|
582 | 582 | |
|
583 | 583 | |
|
584 | 584 | Apache with mod_wsgi |
|
585 | 585 | -------------------- |
|
586 | 586 | |
|
587 | 587 | Alternatively, Kallithea can be set up with Apache under mod_wsgi. For |
|
588 | 588 | that, you'll need to: |
|
589 | 589 | |
|
590 | 590 | - Install mod_wsgi. If using a Debian-based distro, you can install |
|
591 | 591 | the package libapache2-mod-wsgi:: |
|
592 | 592 | |
|
593 | 593 | aptitude install libapache2-mod-wsgi |
|
594 | 594 | |
|
595 | 595 | - Enable mod_wsgi:: |
|
596 | 596 | |
|
597 | 597 | a2enmod wsgi |
|
598 | 598 | |
|
599 | 599 | - Add global Apache configuration to tell mod_wsgi that Python only will be |
|
600 | 600 | used in the WSGI processes and shouldn't be initialized in the Apache |
|
601 | 601 | processes:: |
|
602 | 602 | |
|
603 | 603 | WSGIRestrictEmbedded On |
|
604 | 604 | |
|
605 | 605 | - Create a WSGI dispatch script, like the one below. Make sure you |
|
606 | 606 | check that the paths correctly point to where you installed Kallithea |
|
607 | 607 | and its Python Virtual Environment. |
|
608 | 608 | |
|
609 | 609 | .. code-block:: python |
|
610 | 610 | |
|
611 | 611 | import os |
|
612 | 612 | os.environ['PYTHON_EGG_CACHE'] = '/srv/kallithea/.egg-cache' |
|
613 | 613 | |
|
614 | 614 | # sometimes it's needed to set the current dir |
|
615 | 615 | os.chdir('/srv/kallithea/') |
|
616 | 616 | |
|
617 | 617 | import site |
|
618 | 618 | site.addsitedir("/srv/kallithea/venv/lib/python3.7/site-packages") |
|
619 | 619 | |
|
620 | 620 | ini = '/srv/kallithea/my.ini' |
|
621 | 621 | from logging.config import fileConfig |
|
622 | 622 | fileConfig(ini, {'__file__': ini, 'here': '/srv/kallithea'}) |
|
623 | 623 | from paste.deploy import loadapp |
|
624 | 624 | application = loadapp('config:' + ini) |
|
625 | 625 | |
|
626 | 626 | Or using proper virtualenv activation: |
|
627 | 627 | |
|
628 | 628 | .. code-block:: python |
|
629 | 629 | |
|
630 | 630 | activate_this = '/srv/kallithea/venv/bin/activate_this.py' |
|
631 | 631 | execfile(activate_this, dict(__file__=activate_this)) |
|
632 | 632 | |
|
633 | 633 | import os |
|
634 | 634 | os.environ['HOME'] = '/srv/kallithea' |
|
635 | 635 | |
|
636 | 636 | ini = '/srv/kallithea/kallithea.ini' |
|
637 | 637 | from logging.config import fileConfig |
|
638 | 638 | fileConfig(ini, {'__file__': ini, 'here': '/srv/kallithea'}) |
|
639 | 639 | from paste.deploy import loadapp |
|
640 | 640 | application = loadapp('config:' + ini) |
|
641 | 641 | |
|
642 | 642 | - Add the necessary ``WSGI*`` directives to the Apache Virtual Host configuration |
|
643 | 643 | file, like in the example below. Notice that the WSGI dispatch script created |
|
644 | 644 | above is referred to with the ``WSGIScriptAlias`` directive. |
|
645 | 645 | The default locale settings Apache provides for web services are often not |
|
646 | 646 | adequate, with `C` as the default language and `ASCII` as the encoding. |
|
647 | 647 | Instead, use the ``lang`` parameter of ``WSGIDaemonProcess`` to specify a |
|
648 | 648 | suitable locale. See also the :ref:`overview` section and the |
|
649 | 649 | `WSGIDaemonProcess documentation`_. |
|
650 | 650 | |
|
651 | 651 | Apache will by default run as a special Apache user, on Linux systems |
|
652 | 652 | usually ``www-data`` or ``apache``. If you need to have the repositories |
|
653 | 653 | directory owned by a different user, use the user and group options to |
|
654 | 654 | WSGIDaemonProcess to set the name of the user and group. |
|
655 | 655 | |
|
656 | 656 | Once again, check that all paths are correctly specified. |
|
657 | 657 | |
|
658 | 658 | .. code-block:: apache |
|
659 | 659 | |
|
660 | 660 | WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 \ |
|
661 | 661 | python-home=/srv/kallithea/venv lang=C.UTF-8 |
|
662 | 662 | WSGIProcessGroup kallithea |
|
663 | 663 | WSGIScriptAlias / /srv/kallithea/dispatch.wsgi |
|
664 | 664 | WSGIPassAuthorization On |
|
665 | 665 | |
|
666 | 666 | Or if using a dispatcher WSGI script with proper virtualenv activation: |
|
667 | 667 | |
|
668 | 668 | .. code-block:: apache |
|
669 | 669 | |
|
670 | 670 | WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 lang=en_US.utf8 |
|
671 | 671 | WSGIProcessGroup kallithea |
|
672 | 672 | WSGIScriptAlias / /srv/kallithea/dispatch.wsgi |
|
673 | 673 | WSGIPassAuthorization On |
|
674 | 674 | |
|
675 | 675 | |
|
676 | 676 | Other configuration files |
|
677 | 677 | ------------------------- |
|
678 | 678 | |
|
679 | 679 | A number of `example init.d scripts`__ can be found in |
|
680 | 680 | the ``init.d`` directory of the Kallithea source. |
|
681 | 681 | |
|
682 | 682 | .. __: https://kallithea-scm.org/repos/kallithea/files/tip/init.d/ . |
|
683 | 683 | |
|
684 | 684 | |
|
685 | 685 | .. _python: http://www.python.org/ |
|
686 | 686 | .. _Python regular expression documentation: https://docs.python.org/2/library/re.html |
|
687 | 687 | .. _Mercurial: https://www.mercurial-scm.org/ |
|
688 | 688 | .. _Celery: http://celeryproject.org/ |
|
689 | 689 | .. _Celery documentation: http://docs.celeryproject.org/en/latest/getting-started/index.html |
|
690 | 690 | .. _RabbitMQ: http://www.rabbitmq.com/ |
|
691 | 691 | .. _Redis: http://redis.io/ |
|
692 | 692 | .. _mercurial-server: http://www.lshift.net/mercurial-server.html |
|
693 | 693 | .. _PublishingRepositories: https://www.mercurial-scm.org/wiki/PublishingRepositories |
|
694 | 694 | .. _WSGIDaemonProcess documentation: https://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html |
@@ -1,96 +1,96 b'' | |||
|
1 | 1 | .. _email: |
|
2 | 2 | |
|
3 | 3 | ============== |
|
4 | 4 | Email settings |
|
5 | 5 | ============== |
|
6 | 6 | |
|
7 | 7 | The Kallithea configuration file has several email related settings. When |
|
8 | 8 | these contain correct values, Kallithea will send email in the situations |
|
9 | 9 | described below. If the email configuration is not correct so that emails |
|
10 | 10 | cannot be sent, all mails will show up in the log output. |
|
11 | 11 | |
|
12 | 12 | Before any email can be sent, an SMTP server has to be configured using the |
|
13 | 13 | configuration file setting ``smtp_server``. If required for that server, specify |
|
14 | 14 | a username (``smtp_username``) and password (``smtp_password``), a non-standard |
|
15 | 15 | port (``smtp_port``), whether to use "SSL" when connecting (``smtp_use_ssl``) |
|
16 | 16 | or use STARTTLS (``smtp_use_tls``), and/or specify special ESMTP "auth" features |
|
17 | 17 | (``smtp_auth``). |
|
18 | 18 | |
|
19 | 19 | For example, for sending through gmail, use:: |
|
20 | 20 | |
|
21 | 21 | smtp_server = smtp.gmail.com |
|
22 | 22 | smtp_username = username |
|
23 | 23 | smtp_password = password |
|
24 | 24 | smtp_port = 465 |
|
25 | 25 | smtp_use_ssl = true |
|
26 | 26 | |
|
27 | 27 | |
|
28 | 28 | Application emails |
|
29 | 29 | ------------------ |
|
30 | 30 | |
|
31 | 31 | Kallithea sends an email to `users` on several occasions: |
|
32 | 32 | |
|
33 | 33 | - when comments are given on one of their changesets |
|
34 | 34 | - when comments are given on changesets they are reviewer on or on which they |
|
35 | 35 | commented regardless |
|
36 | 36 | - when they are invited as reviewer in pull requests |
|
37 | 37 | - when they request a password reset |
|
38 | 38 | |
|
39 | 39 | Kallithea sends an email to all `administrators` upon new account registration. |
|
40 | 40 | Administrators are users with the ``Admin`` flag set on the *Admin > Users* |
|
41 | 41 | page. |
|
42 | 42 | |
|
43 | 43 | When Kallithea wants to send an email but due to an error cannot correctly |
|
44 | 44 | determine the intended recipients, the administrators and the addresses |
|
45 | 45 | specified in ``email_to`` in the configuration file are used as fallback. |
|
46 | 46 | |
|
47 | 47 | Recipients will see these emails originating from the sender specified in the |
|
48 | 48 | ``app_email_from`` setting in the configuration file. This setting can either |
|
49 | 49 | contain only an email address, like `kallithea-noreply@example.com`, or both |
|
50 | 50 | a name and an address in the following format: `Kallithea |
|
51 | 51 | <kallithea-noreply@example.com>`. However, if the email is sent due to an |
|
52 | 52 | action of a particular user, for example when a comment is given or a pull |
|
53 | 53 | request created, the name of that user will be combined with the email address |
|
54 | 54 | specified in ``app_email_from`` to form the sender (and any name part in that |
|
55 | 55 | configuration setting disregarded). |
|
56 | 56 | |
|
57 | 57 | The subject of these emails can optionally be prefixed with the value of |
|
58 | 58 | ``email_prefix`` in the configuration file. |
|
59 | 59 | |
|
60 | 60 | A Kallithea-specific header indicating the email type will be added to each |
|
61 | 61 | email. This header can be used for email filtering. The header is of the form: |
|
62 | 62 | |
|
63 | 63 | X-Kallithea-Notification-Type: <type> |
|
64 | 64 | |
|
65 | 65 | where ``<type>`` is one of: |
|
66 | 66 | |
|
67 | 67 | - ``pull_request``: you are invited as reviewer in a pull request |
|
68 | 68 | - ``pull_request_comment``: a comment was given on a pull request |
|
69 | 69 | - ``cs_comment``: a comment was given on a changeset |
|
70 | 70 | - ``registration``: a new user was registered |
|
71 | 71 | - ``message``: another type of email |
|
72 | 72 | |
|
73 | 73 | |
|
74 | 74 | Error emails |
|
75 | 75 | ------------ |
|
76 | 76 | |
|
77 | 77 | When an exception occurs in Kallithea -- and unless interactive debugging is |
|
78 | 78 | enabled using ``set debug = true`` in the ``[app:main]`` section of the |
|
79 | 79 | configuration file -- an email with exception details is sent by backlash_ |
|
80 | 80 | to the addresses specified in ``email_to`` in the configuration file. |
|
81 | 81 | |
|
82 | 82 | Recipients will see these emails originating from the sender specified in the |
|
83 | 83 | ``error_email_from`` setting in the configuration file. This setting can either |
|
84 | 84 | contain only an email address, like `kallithea-noreply@example.com`, or both |
|
85 | 85 | a name and an address in the following format: `Kallithea Errors |
|
86 | 86 | <kallithea-noreply@example.com>`. |
|
87 | 87 | |
|
88 | 88 | |
|
89 | 89 | References |
|
90 | 90 | ---------- |
|
91 | 91 | |
|
92 |
- `Error Middleware (Pylons documentation) <http://pylons-webframework.readthedocs.o |
|
|
93 |
- `ErrorHandler (Pylons modules documentation) <http://pylons-webframework.readthedocs.o |
|
|
92 | - `Error Middleware (Pylons documentation) <https://pylons-webframework.readthedocs.io/en/latest/debugging.html#error-middleware>`_ | |
|
93 | - `ErrorHandler (Pylons modules documentation) <https://pylons-webframework.readthedocs.io/en/latest/modules/middleware.html#pylons.middleware.ErrorHandler>`_ | |
|
94 | 94 | |
|
95 | 95 | |
|
96 | 96 | .. _backlash: https://github.com/TurboGears/backlash |
@@ -1,81 +1,81 b'' | |||
|
1 | 1 | #!/bin/bash |
|
2 | 2 | set -e |
|
3 | 3 | set -x |
|
4 | 4 | |
|
5 | 5 | cleanup() |
|
6 | 6 | { |
|
7 | 7 | echo "Removing venv $venv" |
|
8 | 8 | rm -rf "$venv" |
|
9 | 9 | } |
|
10 | 10 | |
|
11 | 11 | echo "Checking that you are NOT inside a virtualenv" |
|
12 | 12 | [ -z "$VIRTUAL_ENV" ] |
|
13 | 13 | |
|
14 | 14 | venv=$(mktemp -d --tmpdir kallithea-release-XXXXX) |
|
15 | 15 | trap cleanup EXIT |
|
16 | 16 | |
|
17 | 17 | echo "Setting up a fresh virtualenv in $venv" |
|
18 | 18 | python3 -m venv "$venv" |
|
19 | 19 | . "$venv/bin/activate" |
|
20 | 20 | |
|
21 | 21 | echo "Install/verify tools needed for building and uploading stuff" |
|
22 | 22 | pip install --upgrade -e . -r dev_requirements.txt twine python-ldap python-pam |
|
23 | 23 | |
|
24 | 24 | echo "Cleanup and update copyrights ... and clean checkout" |
|
25 | 25 | scripts/run-all-cleanup |
|
26 | 26 | scripts/update-copyrights.py |
|
27 | 27 | hg up -cr . |
|
28 | 28 | |
|
29 | 29 | echo "Make release build from clean checkout in build/" |
|
30 | 30 | rm -rf build dist |
|
31 | 31 | hg archive build |
|
32 | 32 | cd build |
|
33 | 33 | |
|
34 | 34 | echo "Check that each entry in MANIFEST.in match something" |
|
35 | 35 | sed -e 's/[^ ]*[ ]*\([^ ]*\).*/\1/g' MANIFEST.in | xargs ls -lad |
|
36 | 36 | |
|
37 | 37 | echo "Build dist" |
|
38 | 38 | python3 setup.py compile_catalog |
|
39 | 39 | python3 setup.py sdist |
|
40 | 40 | |
|
41 | 41 | echo "Verify VERSION from kallithea/__init__.py" |
|
42 | 42 | namerel=$(cd dist && echo Kallithea-*.tar.gz) |
|
43 | 43 | namerel=${namerel%.tar.gz} |
|
44 | 44 | version=${namerel#Kallithea-} |
|
45 | 45 | ls -l $(pwd)/dist/$namerel.tar.gz |
|
46 | 46 | echo "Releasing Kallithea $version in directory $namerel" |
|
47 | 47 | |
|
48 | 48 | echo "Verify dist file content" |
|
49 | 49 | diff -u <((hg mani | grep -v '^\.hg\|^kallithea/i18n/en/LC_MESSAGES/kallithea.mo$') | LANG=C sort) <(tar tf dist/Kallithea-$version.tar.gz | sed "s|^$namerel/||" | grep . | grep -v '^kallithea/i18n/.*/LC_MESSAGES/kallithea.mo$\|^Kallithea.egg-info/\|^PKG-INFO$\|/$' | LANG=C sort) |
|
50 | 50 | |
|
51 | 51 | echo "Verify docs build" |
|
52 | 52 | python3 setup.py build_sphinx # the results are not actually used, but we want to make sure it builds |
|
53 | 53 | |
|
54 | 54 | echo "Shortlog for inclusion in the release announcement" |
|
55 | 55 | scripts/shortlog.py "only('.', branch('stable') & tagged() & public() & not '.')" |
|
56 | 56 | |
|
57 | 57 | cat - << EOT |
|
58 | 58 | |
|
59 | 59 | Now, make sure |
|
60 | 60 | * all tests are passing |
|
61 | 61 | * release note is ready |
|
62 | 62 | * announcement is ready |
|
63 | 63 | * source has been pushed to https://kallithea-scm.org/repos/kallithea |
|
64 | 64 | |
|
65 | 65 | EOT |
|
66 | 66 | |
|
67 | 67 | echo "Verify current revision is tagged for $version" |
|
68 | 68 | hg log -r "'$version'&." | grep . |
|
69 | 69 | |
|
70 | 70 | echo -n "Enter \"pypi\" to upload Kallithea $version to pypi: " |
|
71 | 71 | read answer |
|
72 | 72 | [ "$answer" = "pypi" ] |
|
73 | 73 | |
|
74 | 74 | echo "Rebuild readthedocs for docs.kallithea-scm.org" |
|
75 | 75 | xdg-open https://readthedocs.org/projects/kallithea/ |
|
76 | 76 | curl -X POST http://readthedocs.org/build/kallithea |
|
77 | 77 | xdg-open https://readthedocs.org/projects/kallithea/builds |
|
78 | xdg-open http://docs.kallithea-scm.org/en/latest/ # or whatever the branch is | |
|
78 | xdg-open https://docs.kallithea-scm.org/en/latest/ # or whatever the branch is | |
|
79 | 79 | |
|
80 | 80 | twine upload dist/* |
|
81 | 81 | xdg-open https://pypi.python.org/pypi/Kallithea |
General Comments 0
You need to be logged in to leave comments.
Login now