doc/book/admin/deploy.rst
branch3.27
changeset 12862 87b00a0cc64d
equal deleted inserted replaced
12861:1983923e51cc 12862:87b00a0cc64d
       
     1 .. -*- coding: utf-8 -*-
       
     2 
       
     3 Deploy a *CubicWeb* application
       
     4 ===============================
       
     5 
       
     6 Deployment with uwsgi
       
     7 ---------------------
       
     8 
       
     9 `uWSGI <https://uwsgi-docs.readthedocs.io/>`_ is often used to deploy CubicWeb
       
    10 applications.
       
    11 
       
    12 Short version is install `uwsgi`:
       
    13 
       
    14 .. sourcecode:: console
       
    15 
       
    16   apt install uwsgi
       
    17 
       
    18 Deploy a configuration file for your application
       
    19 `/etc/uwsgi/apps-enabled/example.ini`:
       
    20 
       
    21 .. sourcecode:: ini
       
    22 
       
    23     [uwsgi]
       
    24     master = true
       
    25     http = 0.0.0.0:8080
       
    26     env = CW_INSTANCE=example
       
    27     wsgi-file = /etc/cubicweb.d/example/wsgiapp.py
       
    28     processes = 8
       
    29     threads = 1
       
    30     plugins = http,python3
       
    31     auto-procname = true
       
    32     lazy-apps = true
       
    33     log-master = true
       
    34     # disable uwsgi request logging
       
    35     disable-logging = true
       
    36     stats = 127.0.0.1:1717
       
    37 
       
    38 The `wsgiapp.py` file looks like this:
       
    39 
       
    40 .. sourcecode:: python
       
    41 
       
    42     import os
       
    43     from cubicweb.pyramid import wsgi_application_from_cwconfig
       
    44     from cubicweb.cwconfig import CubicWebConfiguration as cwcfg
       
    45 
       
    46     appid = os.environ['CW_INSTANCE']  # instance name
       
    47     cwconfig = cwcfg.config_for(appid)
       
    48 
       
    49     cwconfig.log_format = ('{0} pid:{1} (%(name)s) %(levelname)s: %(message)s'
       
    50                            .format(appid, os.getpid()))
       
    51 
       
    52     application = wsgi_application_from_cwconfig(cwconfig)
       
    53     repo = application.application.registry['cubicweb.repository']
       
    54 
       
    55 
       
    56 Deployment with SaltStack
       
    57 -------------------------
       
    58 
       
    59 To deploy with SaltStack one can refer themselves to the
       
    60 `cubicweb-formula <https://hg.logilab.org/master/salt/cubicweb-formula/>`_.
       
    61 
       
    62 Deployment with Kubernetes
       
    63 --------------------------
       
    64 
       
    65 To deploy in a Kubernetes cluster, you can take inspiration from the
       
    66 instructions included in
       
    67 `the fresh cube  <https://hg.logilab.org/master/cubes/fresh/file/tip/README.rst#l20>`_
       
    68 and the `deployment yaml files <https://hg.logilab.org/master/cubes/fresh/file/tip/deploy>`_.