Difference between revisions of "Uwsgi"
Line 10: | Line 10: | ||
==Installing== | ==Installing== | ||
* pip3 install uwsgi | * pip3 install uwsgi | ||
− | * | + | * pip3 install flask |
− | |||
− | |||
− | |||
− | + | ==Configuration== | |
+ | |||
+ | /etc/uwsgi-emperor/emperor.ini | ||
+ | [uwsgi] | ||
+ | autoload = true | ||
+ | no-orphan = true | ||
+ | emperor = /etc/uwsgi-emperor/vassals | ||
+ | master = true | ||
+ | emperor-nofollow = true | ||
+ | processes = 1 | ||
+ | workers = 2 | ||
+ | uid = www-data | ||
+ | gid = www-data | ||
+ | pidfile = /run/uwsgi/pid | ||
+ | socket = /tmp/%n.sock | ||
+ | chmod-socket = 666 | ||
+ | chown-socket = www-data | ||
+ | log-date = false | ||
+ | |||
+ | For all applications you can use this configuration file in /etc/uwsgi-emperor/vassels/app1.ini | ||
+ | |||
+ | [uwsgi] | ||
+ | plugins = python3 | ||
+ | master = false | ||
+ | processes = 1 | ||
+ | vaccum = true | ||
+ | chmod-socket = 666 | ||
+ | socket = /tmp/%n.sock | ||
+ | uid = www-data | ||
+ | gid = www-data | ||
+ | pythonpath = /opt/flask/%n | ||
+ | module = %n | ||
+ | |||
+ | The %n will be replaced by the first part of the file-name (app1 in this example). In /opt/flask/app1 you can put your code. | ||
+ | |||
+ | ==Starting== | ||
+ | The command is: | ||
+ | <code>/usr/local/bin/uwsgi -d --ini /etc/uwsgi-emperor/emperor.ini --log-syslog</code> | ||
+ | |||
+ | This logs to the [[rsyslog]] daemon. Add following line to the rsyslogd configuration to have uwsgi log to a different file: | ||
+ | :programname, contains, "uwsgi" /var/log/uwsgi/uwsgi.log | ||
Revision as of 14:17, 14 July 2021
Lots of confusion going around on the net about installing and using uwsgi. Here my notes.
Used documentation
https://github.com/unbit/uwsgi/issues/1688
https://stackoverflow.com/questions/35262299/uwsgi-emperor-mode-not-working-outside-of-virtualenv
Installing
- pip3 install uwsgi
- pip3 install flask
Configuration
/etc/uwsgi-emperor/emperor.ini
[uwsgi] autoload = true no-orphan = true emperor = /etc/uwsgi-emperor/vassals master = true emperor-nofollow = true processes = 1 workers = 2 uid = www-data gid = www-data pidfile = /run/uwsgi/pid socket = /tmp/%n.sock chmod-socket = 666 chown-socket = www-data log-date = false
For all applications you can use this configuration file in /etc/uwsgi-emperor/vassels/app1.ini
[uwsgi] plugins = python3 master = false processes = 1 vaccum = true chmod-socket = 666 socket = /tmp/%n.sock uid = www-data gid = www-data pythonpath = /opt/flask/%n module = %n
The %n will be replaced by the first part of the file-name (app1 in this example). In /opt/flask/app1 you can put your code.
Starting
The command is:
/usr/local/bin/uwsgi -d --ini /etc/uwsgi-emperor/emperor.ini --log-syslog
This logs to the rsyslog daemon. Add following line to the rsyslogd configuration to have uwsgi log to a different file:
:programname, contains, "uwsgi" /var/log/uwsgi/uwsgi.log
Stopping
Several suggestions made on the web:
This works:
kill `pidof uwsgi`
Other suggestion that looks cleaner:
uwsgi --stop /run/uwsgi/pid
(or whereever your pid-file is)