second submodule: website_house_booking
[odoo/odoo.git] / doc / deployment-gunicorn.rst
1 .. _using-gunicorn:
2
3 Deploying with Gunicorn
4 =======================
5
6 Starting with OpenERP 6.1, the server and web addons are WSGI_ compliant. In
7 particular, support for the Gunicorn_ HTTP server is available. For some
8 background information and motivation, please read http://www.openerp.com/node/1106.
9 To install Gunicorn, please refer to Gunicorn's website.
10
11 .. _Gunicorn: http://gunicorn.org/
12 .. _WSGI: http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
13
14 Summary
15 -------
16
17 Configuring and starting an OpenERP server with Gunicorn is straightfoward. The
18 different sections below give more details but the following steps are all it
19 takes:
20
21 1. Use a configuration file, passing it to ``gunicorn`` using the ``-c``
22    option.
23 2. Within the same configuration file, also configure OpenERP.
24 3. Run ``gunicorn openerp:service.wsgi_server.application -c openerp-wsgi.py``.
25
26 Sample configuration file
27 -------------------------
28
29 A sample ``openerp-wsgi.py`` configuration file for WSGI servers can be found
30 in the OpenERP server source tree. It is fairly well commented and easily
31 customizable for your own usage. While reading the remaining of this page, it
32 is advised you take a look at the sample ``openerp-wsgi.py`` file as it makes
33 things easier to follow.
34
35 Configuration
36 -------------
37
38 Gunicorn can be configured by a configuration file and/or command-line
39 arguments. For a list of available options, you can refer to the official
40 Gunicorn documentation http://docs.gunicorn.org/en/latest/configure.html.
41
42 When the OpenERP server is started on its own, by using the ``openerp-server``
43 script, it can also be configured by a configuration file or its command-line
44 arguments. But when it is run via Gunicorn, it is no longer the case. Instead,
45 as the Gunicorn configuration file is a full-fledged Python file, we can
46 ``import openerp`` in it and configure directly the server.
47
48 The principle can be summarized with this three lines (although they are spread
49 across the whole sample ``openerp-wsgi.py`` file)::
50
51   import openerp
52   conf = openerp.tools.config
53   conf['addons_path'] = '/home/openerp/addons/trunk,/home/openerp/web/trunk/addons'
54
55 The above three lines first import the ``openerp`` library (i.e. the one
56 containing the OpenERP server implementation). The second one is really to
57 shorten repeated usage of the same variable. The third one sets a parameter, in
58 this case the equivalent of the ``--addons-path`` command-line option.
59
60 Running
61 -------
62
63 Once a proper configuration file is available, running the OpenERP server with
64 Gunicorn can be done with the following command::
65
66   > gunicorn openerp:service.wsgi_server.application -c openerp-wsgi.py
67
68 ``openerp`` must be importable by Python. The simplest way is to run the above
69 command from the server source directory (i.e. the directory containing the
70 ``openerp`` module). Alternatively, the module can be installed on your machine
71 as a regular Python library or added to your ``PYTHONPATH``.
72