[FIX+DOC] added doc for deployment under mod_wsgi + a fix for that use case.
authorVo Minh Thu <vmt@openerp.com>
Tue, 5 Feb 2013 17:23:41 +0000 (18:23 +0100)
committerVo Minh Thu <vmt@openerp.com>
Tue, 5 Feb 2013 17:23:41 +0000 (18:23 +0100)
bzr revid: vmt@openerp.com-20130205172341-pwh0z4go2xsdz7n1

doc/deployment-mod-wsgi.rst [new file with mode: 0644]
doc/index.rst
openerp/netsvc.py

diff --git a/doc/deployment-mod-wsgi.rst b/doc/deployment-mod-wsgi.rst
new file mode 100644 (file)
index 0000000..82b1a50
--- /dev/null
@@ -0,0 +1,58 @@
+.. _using-mod-wsgi:
+
+Deploying with ``mod_wsgi``
+===========================
+
+``mod_wsgi`` makes it possible to run a WSGI_ application (such as OpenERP)
+under the Apache_ HTTP server.
+
+.. _WSGI: http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
+.. _Apache: https://httpd.apache.org/
+
+Summary
+-------
+
+Similarly to :doc:`deployment-gunicorn`, running OpenERP behind Apache with
+``mod_wsgi`` requires to modify the sample ``openerp-wsgi.py`` script.
+For instance, make sure to correctly set the ``addons_path`` configuration
+(using absolute paths). Then that Python script can be set in the Apache
+configuration.
+
+Configuration
+-------------
+
+In Apache's configuration, add the line
+
+::
+
+  LoadModule wsgi_module modules/mod_wsgi.so
+
+to activate ``mod_wsgi``.
+
+Then a possible configuration is as follow::
+
+  WSGIScriptAlias / /home/thu/repos/server/trunk/openerp-wsgi.py
+  WSGIDaemonProcess oe user=thu group=users processes=2 python-path=/home/thu/repos/server/trunk/ display-name=apache-openerp
+  WSGIProcessGroup oe
+
+  <Directory /home/thu/repos/server/trunk>
+      Order allow,deny
+      Allow from all
+  </Directory>
+
+The ``WSGIScriptAlias`` directive indicates that any URL matching ``/`` will
+run the application defined in the ``openerp-wsgi.py`` script.
+
+The ``WSGIDaemonProcess`` and ``WSGIProcessGroup`` directives create a process
+configuration. The configuration makes it possible for isntance to specify
+which user runs the OpenERP process.
+
+Finally, it is necessary to make sure the source directory where the script can
+be found is allowed by Apache with the ``Directory`` block.
+
+Running
+-------
+
+When the Apache configuration changes, it is necessary to restart Apache, e.g. with::
+
+  /etc/init.d/httpd restart
index 33474e2..e5918e0 100644 (file)
@@ -17,6 +17,7 @@ OpenERP Server
    05_test_framework
    06_misc
    deployment-gunicorn
+   deployment-mod-wsgi
 
 OpenERP Command
 '''''''''''''''
index 533b165..d6f9dc4 100644 (file)
@@ -186,7 +186,13 @@ def init_logger():
         # Normal Handler on standard output
         handler = logging.StreamHandler(sys.stdout)
 
-    if isinstance(handler, logging.StreamHandler) and os.isatty(handler.stream.fileno()):
+    # Check that handler.stream has a fileno() method: when running OpenERP
+    # behind Apache with mod_wsgi, handler.stream will have type mod_wsgi.Log,
+    # which has no fileno() method. (mod_wsgi.Log is what is being bound to
+    # sys.stderr when the logging.StreamHandler is being constructed above.)
+    if isinstance(handler, logging.StreamHandler) \
+        and hasattr(handler.stream, 'fileno') \
+        and os.isatty(handler.stream.fileno()):
         formatter = ColoredFormatter(format)
     else:
         formatter = DBFormatter(format)