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