summaryrefslogtreecommitdiff
path: root/docs/admin/installation-uwsgi.rst
blob: 72498c0bfb3d7d8056eb15e04192280385889236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
.. _searx uwsgi:

=====
uwsgi
=====

.. sidebar:: further reading

   - `systemd.unit`_
   - `uWSGI Emperor`_

.. contents:: Contents
   :depth: 2
   :local:
   :backlinks: entry


.. _systemd.unit: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
.. _One service per app in systemd:
    https://uwsgi-docs.readthedocs.io/en/latest/Systemd.html#one-service-per-app-in-systemd
.. _uWSGI Emperor:
    https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html
.. _uwsgi ini file:
   https://uwsgi-docs.readthedocs.io/en/latest/Configuration.html#ini-files
.. _systemd unit template:
   http://0pointer.de/blog/projects/instances.html


Origin uWSGI
============

How uWSGI is implemented by distributors is different.  uWSGI itself
recommend two methods

`systemd.unit`_ template files as described here `One service per app in systemd`_.

  There is one `systemd unit template`_ and one `uwsgi ini file`_ per uWSGI-app
  placed at dedicated locations.  Take archlinux and a searx.ini as example::

    unit template    -->  /usr/lib/systemd/system/uwsgi@.service
    uwsgi ini files  -->  /etc/uwsgi/searx.ini

  The searx app can be maintained as know from common systemd units::

    systemctl enable  uwsgi@searx
    systemctl start   uwsgi@searx
    systemctl restart uwsgi@searx
    systemctl stop    uwsgi@searx

The `uWSGI Emperor`_ mode which fits for maintaining a large range of uwsgi apps.

  The Emperor mode is a special uWSGI instance that will monitor specific
  events.  The Emperor mode (service) is started by a (common, not template)
  systemd unit.  The Emperor service will scan specific directories for `uwsgi
  ini file`_\s (also know as *vassals*).  If a *vassal* is added, removed or the
  timestamp is modified, a corresponding action takes place: a new uWSGI
  instance is started, reload or stopped.  Take Fedora and a searx.ini as
  example::

    to start a new searx instance create   --> /etc/uwsgi.d/searx.ini
    to reload the instance edit timestamp  --> touch /etc/uwsgi.d/searx.ini
    to stop instance remove ini            --> rm /etc/uwsgi.d/searx.ini

Distributors
============

The `uWSGI Emperor`_ mode and `systemd unit template`_ is what the distributors
mostly offer their users, even if they differ in the way they implement both
modes and their defaults.  Another point they might differ is the packaging of
plugins (if so, compare :ref:`install packages`) and what the default python
interpreter is (python2 vs. python3).

Fedora starts a Emperor by default, while archlinux does not start any uwsgi
service by default.  Worth to know; debian (ubuntu) follow a complete different
approach.  *debian*: your are familiar with the apache infrastructure? .. they
do similar for the uWSGI infrastructure (with less comfort), the folders are::

    /etc/uwsgi/apps-available/
    /etc/uwsgi/apps-enabled/

The `uwsgi ini file`_ is enabled by a symbolic link::

  ln -s /etc/uwsgi/apps-available/searx.ini /etc/uwsgi/apps-enabled/

From debian's documentation (``/usr/share/doc/uwsgi/README.Debian.gz``): You
could control specific instance(s) by issuing::

  service uwsgi <command> <confname> <confname> ...

  sudo -H service uwsgi start searx
  sudo -H service uwsgi stop  searx

My experience is, that this command is a bit buggy.

.. _uwsgi configuration:

Alltogether
===========

Create the configuration ini-file according to your distribution (see below) and
restart the uwsgi application.

.. tabs::

   .. group-tab:: Ubuntu / debian

      .. literalinclude:: ../../build/docs/includes/searx.rst
         :start-after: START searx uwsgi-description ubuntu-20.04
         :end-before: END searx uwsgi-description ubuntu-20.04


   .. group-tab:: Arch Linux

      .. literalinclude:: ../../build/docs/includes/searx.rst
         :start-after: START searx uwsgi-description arch
         :end-before: END searx uwsgi-description arch


   .. group-tab::  Fedora / RHEL

      .. literalinclude:: ../../build/docs/includes/searx.rst
         :start-after: START searx uwsgi-description fedora
         :end-before: END searx uwsgi-description fedora


.. tabs::

   .. group-tab:: Ubuntu / debian

      .. literalinclude:: ../../build/docs/includes/searx.rst
         :language: ini
         :start-after: START searx uwsgi-appini ubuntu-20.04
         :end-before: END searx uwsgi-appini ubuntu-20.04

   .. group-tab:: Arch Linux

      .. literalinclude:: ../../build/docs/includes/searx.rst
         :language: ini
         :start-after: START searx uwsgi-appini arch
         :end-before: END searx uwsgi-appini arch

   .. group-tab::  Fedora / RHEL

      .. literalinclude:: ../../build/docs/includes/searx.rst
         :language: ini
         :start-after: START searx uwsgi-appini fedora
         :end-before: END searx uwsgi-appini fedora