installation-uwsgi.rst 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. .. _searx uwsgi:
  2. =====
  3. uwsgi
  4. =====
  5. .. sidebar:: further reading
  6. - `systemd.unit`_
  7. - `uWSGI Emperor`_
  8. .. contents:: Contents
  9. :depth: 2
  10. :local:
  11. :backlinks: entry
  12. .. _systemd.unit: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
  13. .. _One service per app in systemd:
  14. https://uwsgi-docs.readthedocs.io/en/latest/Systemd.html#one-service-per-app-in-systemd
  15. .. _uWSGI Emperor:
  16. https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html
  17. .. _uwsgi ini file:
  18. https://uwsgi-docs.readthedocs.io/en/latest/Configuration.html#ini-files
  19. .. _systemd unit template:
  20. http://0pointer.de/blog/projects/instances.html
  21. Origin uWSGI
  22. ============
  23. How uWSGI is implemented by distributors is different. uWSGI itself
  24. recommend two methods
  25. `systemd.unit`_ template files as described here `One service per app in systemd`_.
  26. There is one `systemd unit template`_ and one `uwsgi ini file`_ per uWSGI-app
  27. placed at dedicated locations. Take archlinux and a searx.ini as example::
  28. unit template --> /usr/lib/systemd/system/uwsgi@.service
  29. uwsgi ini files --> /etc/uwsgi/searx.ini
  30. The searx app can be maintained as know from common systemd units::
  31. systemctl enable uwsgi@searx
  32. systemctl start uwsgi@searx
  33. systemctl restart uwsgi@searx
  34. systemctl stop uwsgi@searx
  35. The `uWSGI Emperor`_ mode which fits for maintaining a large range of uwsgi apps.
  36. The Emperor mode is a special uWSGI instance that will monitor specific
  37. events. The Emperor mode (service) is started by a (common, not template)
  38. systemd unit. The Emperor service will scan specific directories for `uwsgi
  39. ini file`_\s (also know as *vassals*). If a *vassal* is added, removed or the
  40. timestamp is modified, a corresponding action takes place: a new uWSGI
  41. instance is started, reload or stopped. Take Fedora and a searx.ini as
  42. example::
  43. to start a new searx instance create --> /etc/uwsgi.d/searx.ini
  44. to reload the instance edit timestamp --> touch /etc/uwsgi.d/searx.ini
  45. to stop instance remove ini --> rm /etc/uwsgi.d/searx.ini
  46. Distributors
  47. ============
  48. The `uWSGI Emperor`_ mode and `systemd unit template`_ is what the distributors
  49. mostly offer their users, even if they differ in the way they implement both
  50. modes and their defaults. Another point they might differ is the packaging of
  51. plugins (if so, compare :ref:`install packages`) and what the default python
  52. interpreter is (python2 vs. python3).
  53. Fedora starts a Emperor by default, while archlinux does not start any uwsgi
  54. service by default. Worth to know; debian (ubuntu) follow a complete different
  55. approach. *debian*: your are familiar with the apache infrastructure? .. they
  56. do similar for the uWSGI infrastructure (with less comfort), the folders are::
  57. /etc/uwsgi/apps-available/
  58. /etc/uwsgi/apps-enabled/
  59. The `uwsgi ini file`_ is enabled by a symbolic link::
  60. ln -s /etc/uwsgi/apps-available/searx.ini /etc/uwsgi/apps-enabled/
  61. From debian's documentation (``/usr/share/doc/uwsgi/README.Debian.gz``): You
  62. could control specific instance(s) by issuing::
  63. service uwsgi <command> <confname> <confname> ...
  64. sudo -H service uwsgi start searx
  65. sudo -H service uwsgi stop searx
  66. My experience is, that this command is a bit buggy.
  67. .. _uwsgi configuration:
  68. All together
  69. ============
  70. Create the configuration ini-file according to your distribution (see below) and
  71. restart the uwsgi application.
  72. .. tabs::
  73. .. group-tab:: Ubuntu / debian
  74. .. kernel-include:: $DOCS_BUILD/includes/searx.rst
  75. :start-after: START searx uwsgi-description ubuntu-20.04
  76. :end-before: END searx uwsgi-description ubuntu-20.04
  77. .. hotfix: a bug group-tab need this comment
  78. .. group-tab:: Arch Linux
  79. .. kernel-include:: $DOCS_BUILD/includes/searx.rst
  80. :start-after: START searx uwsgi-description arch
  81. :end-before: END searx uwsgi-description arch
  82. .. hotfix: a bug group-tab need this comment
  83. .. group-tab:: Fedora / RHEL
  84. .. kernel-include:: $DOCS_BUILD/includes/searx.rst
  85. :start-after: START searx uwsgi-description fedora
  86. :end-before: END searx uwsgi-description fedora
  87. .. tabs::
  88. .. group-tab:: Ubuntu / debian
  89. .. kernel-include:: $DOCS_BUILD/includes/searx.rst
  90. :start-after: START searx uwsgi-appini ubuntu-20.04
  91. :end-before: END searx uwsgi-appini ubuntu-20.04
  92. .. hotfix: a bug group-tab need this comment
  93. .. group-tab:: Arch Linux
  94. .. kernel-include:: $DOCS_BUILD/includes/searx.rst
  95. :start-after: START searx uwsgi-appini arch
  96. :end-before: END searx uwsgi-appini arch
  97. .. hotfix: a bug group-tab need this comment
  98. .. group-tab:: Fedora / RHEL
  99. .. kernel-include:: $DOCS_BUILD/includes/searx.rst
  100. :start-after: START searx uwsgi-appini fedora
  101. :end-before: END searx uwsgi-appini fedora