uWSGI + Gevent not receiving requests from Nginx - python-3.x

I'm new to uWSGI/gevent and I have a Python Flask Server with Flask-SocketIo sitting behind Nginx, and the server appears to freeze whenever gevent's loop engine runs. A sample output is shown below:
compiled with version: 7.5.0 on 15 April 2020 12:57:22
os: Linux-4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020
nodename: xxxxxxxxxx
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /home/admin/myapplication
detected binary path: /home/admin/myapplication/venv/bin/uwsgi
your processes number limit is 3838
your memory page size is 4096 bytes
detected max file descriptor number: 1024
- async cores set to 1000 - fd table size: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address connect.sock fd 3
Python version: 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0]
Python main interpreter initialized at 0x55701b9d6e40
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 21036928 bytes (20543 KB) for 1000 cores
*** Operational MODE: async ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x55701b9d6e40 pid: 2692 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2692)
spawned uWSGI worker 1 (pid: 2710, cores: 1000)
*** running gevent loop engine [addr:0x557019f92410] ***
At this point, the program produces no further output, despite me attempting to access the page (where I get an Error 502 Bad Gateway).
The app is run via a service file, and it appears to work fine when I run the app directly from the command line. Can anyone identify the issue in my code? (Thanks in advance)
Here is a copy of my service files:
connect.service
[Unit]
Description= xxxxxxxxxxxx
After=network.target
[Service]
User=admin
Group=www-data
WorkingDirectory=/home/admin/myapplication
Environment="PATH=/home/admin/myapplication/venv/bin"
ExecStart=/home/admin/myapplication/venv/bin/uwsgi --ini service_files/connect.ini
[Install]
WantedBy=multi-user.target
connect.ini
[uwsgi]
module = wsgi:app
master = true
gevent = 1000
http-websockets = true
socket = connect.sock
chmod-socket = 660
vacuum = true
logto = /home/admin/myapplication/service_files/logs/uwsgi/%n.log
die-on-term = true
Nginx site
server {
listen 80;
server_name subdomain.domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /home/admin/myapplication/service_files/connect.crt;
ssl_certificate_key /home/admin/myapplication/service_files/connect.key;
server_name subdomain.domain.com;
location / {
include uwsgi_params;
uwsgi_pass unix:///home/admin/myapplication/connect.sock;
}
location /socket.io/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
include uwsgi_params;
uwsgi_pass unix:///home/admin/myapplication/connect.sock;
}
}

The issue was due to a permission error (after more digging using the command sudo tail -30 /var/log/nginx/error.log)
Going to the connect.ini file and changing chmod-socket = 660 to chmod-socket = 666 solved the problem.

Related

uWSGI +nginx setup - Dash (Plotly) Deployment

I’m new to flask and the deployment procedure
I have my dash.py setup as so
server = flask.Flask(__name__)
app = dash.Dash(__name__, server=server)
and my nginx file as such
server {
listen 80;
server_name localhost;
charset utf-8;
client_max_body_size 75M;
location / {try_files $uri #yourapplication; }
location #yourapplication {
include uwsgi_params;
uwsgi_pass unix:/var/www/School-Dashboard/dash_clean.sock;
}
}
…but i’m not sure what i have to set the module parameter to in my wsgi ini file.
[uwsgi]
#application's base folder
base = /var/www/School-Dahboard
#python module to import
module = dash_clean:app #?????? WHAT DO I DO HERE
#home = %(base)/venv
pythonpath = %(base)
#socket file's location
socket = /var/www/School-Dashboard/dash_clean.sock
#permissions for the socket file
chmod-socket = 660
#location of log files
logto = /var/log/uwsgi/%n.log
I keep getting a bad gateway error because of my uwsgi file.
This is the log from uwsgi.
Starting uWSGI 2.0.17.1 (64bit) on [Mon Nov 5 12:47:42 2018] ***
compiled with version: 5.4.0 20160609 on 03 November 2018 06:53:29
os: Linux-4.15.0-36-generic #39~16.04.1-Ubuntu SMP Tue Sep 25 08:59:23 UTC 2018
nodename: xxxxxxxx
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /var/www/School-Dashboard
detected binary path: /home/concent/.local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 31145
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/www/School-Dashboard/dash_clean.sock fd 3
Python version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x22b9330
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
added /var/www/School-Dahboard to pythonpath.
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x22b9330 pid: 20070 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 20070, cores: 1)
So i've set up nginx as so...
server {
server_name 0.0.0.0;
listen 80;
root /home/ubuntu/school_dashboard;
client_max_body_size 200M;
include /etc/nginx/default.d/*.conf;
location /dependencies {
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_pass http://0.0.0.0:5005;
#index wsgi.py
include uwsgi_params;
uwsgi_pass unix:/home/ubuntu/school_dashboard/dependencies/urlgen.sock;
}
}
and my uwsgi file as....
[uwsgi]
module = dash_clean:server
master = true
processes = 5
socket = dashboard.sock
chmod-socket = 660
vacuum = true
die-on-term = true
I just had to change the module parameter
The module parameter should be
module = dash:server
This is because the module is actually the name of your python file that instantiates the flask application instance. In this case it's in your dash.py. Although, in your subsequent comments you seem to reference dash_clean.py, in that case it should be:
module = dash_clean:server
The part after the module name is the name of the "callable", or the name of the variable that is the flask application.
You define it in your code example as:
server = flask.Flask(__name__)
Alternatively, you could define them seperately in the ini
module = dash
callable = server

Apache webserver for MaxRequestWorkers

I am using Apache web server and I am testing my application using Apache benchmark (a tool to hit the http request concurrently), When I use till 300 concurrent requests it is succeeding but when It crosses 300. few requests are failing with SSL handshake failed (5). I understand that Apache web server has 256 request limitation, So I increased the MaxRequestWorkers to 1000 still I get the SSL handshake failure error for few request.
Could someone please check this configuration and let me know the issue in my environment.
Configuration of Apache server:
1) httpd version,
# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Oct 19 2017 20:39:16
2) I checked the status using the following command,
# systemctl status httpd -l
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2018-03-07 23:46:32 IST; 1min 55s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 4351 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
Main PID: 4359 (httpd)
Status: "Total requests: 264; Current requests/sec: 0.1; Current traffic: 204 B/sec"
CGroup: /system.slice/httpd.service
├─4359 /usr/sbin/httpd -DFOREGROUND
├─4360 /usr/sbin/httpd -DFOREGROUND
├─4362 /usr/sbin/httpd -DFOREGROUND
├─5100 /usr/sbin/httpd -DFOREGROUND
├─5386 /usr/sbin/httpd -DFOREGROUND
├─5415 /usr/sbin/httpd -DFOREGROUND
└─5416 /usr/sbin/httpd -DFOREGROUND
3) Since the httpd is pointing to the path : /usr/lib/systemd/system/httpd.service
vi /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
4) As per the above command I found the env file is available '/etc/sysconfig/httpd'
vi /etc/sysconfig/httpd
#
# This file can be used to set additional environment variables for
# the httpd process, or pass additional options to the httpd
# executable.
#
# Note: With previous versions of httpd, the MPM could be changed by
# editing an "HTTPD" variable here. With the current version, that
# variable is now ignored. The MPM is a loadable module, and the
# choice of MPM can be changed by editing the configuration file
/etc/httpd/conf.modules.d/00-mpm.conf
#
#
# To pass additional options (for instance, -D definitions) to the
# httpd binary at startup, set OPTIONS here.
#
#OPTIONS=
#
# This setting ensures the httpd process is started in the "C" locale
# by default. (Some modules will not behave correctly if
# case-sensitive string comparisons are performed in a different
# locale.)
#
LANG=C
5) As per the above command, I found that the conf fileis available in the path : /etc/httpd/conf.modules.d/00-mpm.conf
vi /etc/httpd/conf.modules.d/00-mpm.conf
# Select the MPM module which should be used by uncommenting exactly
# one of the following LoadModule lines:
# prefork MPM: Implements a non-threaded, pre-forking web server
# See: http://httpd.apache.org/docs/2.4/mod/prefork.html
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
# worker MPM: Multi-Processing Module implementing a hybrid
# multi-threaded multi-process web server
# See: http://httpd.apache.org/docs/2.4/mod/worker.html
#
LoadModule mpm_worker_module modules/mod_mpm_worker.so
# event MPM: A variant of the worker MPM with the goal of consuming
# threads only for connections with active processing
# See: http://httpd.apache.org/docs/2.4/mod/event.html
#
#LoadModule mpm_event_module modules/mod_mpm_event.so
<IfModule mpm_worker_module>
ServerLimit 1000
MaxRequestWorkers 1000
</IfModule>
What is wrong with my Apache configuration? Why it is not serving 1000 concurrent request? How to achieve more concurrent request in Apache web server?

Unable to load app 0 (mountpoint='') (callable not found or import error)

I have the below error with nginx uWSGI Flask application on CentOS 7 Linux:
unable to load app 0 (mountpoint='') (callable not found or import error)
I have followed Digital Ocean tut as my first time with Linux, after original Udemy tut using earlier Centos version didnt seem to work. I was able to get 'Hello world' type basic Python file to run on uwsgi and nginx following the tut, then I see several people have this error but seem different solutions. I changed permissions recursively on a parent folder above the app as I thought permissions might be source of error:
sudo chmod -R 771 www
and also giving nginx access to ?my user group? as Dig Ocean tutorial advised:
sudo usermod -a -G will nginx
chmod 710 /home/will
uwsgi.ini file is following, where /var/www/html/CON29Application1/Source/app.py is the app I want to run, not sure if module line is correct syntax:
[uwsgi]
module = Source.app
master = true
socket = /var/www/html/CON29Application1/socket.sock
chmod-socket = 777
vacuum = true
processes = 8
threads = 8
harakiri = 15
logto = /var/www/html/CON29Application1/log/%n.log
die-on-term = true
Systemd file is this at /etc/systemd/system/CON29Application1.service:
[Unit]
Description=uWSGI instance to serve CON29Application1
After=network.target
[Service]
User=will
Group=nginx
WorkingDirectory=/var/www/html/CON29Application1
Environment="PATH=/var/www/html/CON29Application1/venv/bin"
ExecStart=/var/www/html/CON29Application1/venv/bin/uwsgi --ini uwsgi.ini
[Install]
WantedBy=multi-user.target
This is default.conf file at /etc/nginx/conf.d/default.conf (server IP I blanked in this post for security reasons):
server {
listen 80;
server_name 188.xxx.xxx.xxx;
location / {
include uwsgi_params;
uwsgi_pass unix:/var/www/html/CON29Application1/socket.sock;
uwsgi_modifier1 30;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
and this is app.py file:
from flask import Flask, render_template
...
app = Flask(__name__)
app.config.from_object('Source.config')
app.secret_key = "---------------------------------"
...
And sorry as I am not that sure which files are relevant to include, so here is also the full uwsgi.log file! Thanks for any ideas:
*** Starting uWSGI 2.0.15 (64bit) on [Wed Oct 4 13:26:19 2017] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-16) on 02 October 2017 21:47:33
os: Linux-3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017
nodename: CON29Application1
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /var/www/html/CON29Application1
detected binary path: /var/www/html/CON29Application1/venv/bin/uwsgi
your processes number limit is 1792
your memory page size is 4096 bytes
*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/www/html/CON29Application1/socket.sock fd 3
Python version: 3.6.2 (default, Sep 27 2017, 16:30:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Python main interpreter initialized at 0x9acbd0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1304064 bytes (1273 KB) for 64 cores
*** Operational MODE: preforking+threaded ***
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 24254)
spawned uWSGI worker 1 (pid: 24259, cores: 8)
spawned uWSGI worker 2 (pid: 24260, cores: 8)
spawned uWSGI worker 3 (pid: 24261, cores: 8)
spawned uWSGI worker 4 (pid: 24262, cores: 8)
spawned uWSGI worker 5 (pid: 24263, cores: 8)
spawned uWSGI worker 6 (pid: 24264, cores: 8)
spawned uWSGI worker 7 (pid: 24265, cores: 8)
spawned uWSGI worker 8 (pid: 24266, cores: 8) 

UWSGI https configuration for ubuntu

I have django app that is running using the following uwsgi configuration in redhat 7.3:
[uwsgi]
project = helloworld
base = %d
chdir=%(base)
module=helloworld.wsgi:application
plugins = router_redirect
route-if = equal:${HTTPS};on addheader:Strict-Transport-Security: max-age=31536000
master = true
processes = 1
enable-threads = true
threads = 1
max-requests = 2000
shared-socket = 0.0.0.0:443
https = =0,cert/hello.crt,cert/hello.key,HIGH
pidfile = hello_uwsgi.pid
vacuum = true
die-on-term = true
However, when I run it on Ubuntu 16.04.1 LTS, I got the following error:
your processes number limit is 31283
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
Python version: 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609]
Python main interpreter initialized at 0x1dfabe0
python threads support enabled
The -s/--socket option is missing and stdin is not a socket.
VACUUM: pidfile removed.
Does the error means that uwsgi fail to bind the port?
Is there a special way of using "shared-socket" in ubuntu?
I need to have this running on both port 443 and 8443. I have tried the above configuration for both port 443 and 8443 without success.
Thanks in advance.
I got this to work in ubuntu by reinstalling the python 3.5.2 from source.
I am guessing that there is some issue/incompatibility installing python 3.5.2 using apt-get.

Uwsgi emperor has no vassals

I am trying to set up nginx to work with uwsgi, I am on Arch Linux. I have /etc/uwsgi/emperor.ini and /etc/uwsgi/vassals/myapp.ini. My emperor.ini looks like:
[uwsgi]
emperor = /etc/uwsgi/vassals
emperor-pidfile = /run/uwsgi/uwsgi.pid
uid = http
gid = http
logto = /var/log/uwsgi/uwsgi.log
myapp.ini
[uwsgi]
chdir = /srv/http/myapp/src/
wsgi-file = run.py
callable = app
processes = 4
threads = 2
offload-threads = 2
stats = 127.0.0.1:9191
max-requests = 5000
master = True
vacuum = True
socket = 127.0.0.1:3031
enable-threads = true
harakiri = 60
logto = /var/log/uwsgi/myapp.log
uwsgi.service [for systemd]
[Unit]
Description=uWSGI Emperor
After=syslog.target
[Service]
PIDFile=/run/uwsgi/uwsgi.pid
ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown http:http /run/uwsgi
ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi/emperor.ini
Restart=always
Type=notify
StandardError=syslog
NotifyAccess=main
[Install]
WantedBy=multi-user.target
Yet when the uwsgi.service runs I get:
uwsgi.service - uWSGI Emperor
Loaded: loaded (/etc/systemd/system/uwsgi.service; disabled)
Active: active (running) since Sun 2014-02-02 04:37:04 PST; 34min ago
Process: 31537 ExecStartPre=/bin/chown http:http /run/uwsgi (code=exited, status=0/SUCCESS)
Process: 31535 ExecStartPre=/bin/mkdir -p /run/uwsgi (code=exited, status=0/SUCCESS)
Main PID: 31540 (uwsgi)
Status: "The Emperor is governing 0 vassals"
CGroup: /system.slice/uwsgi.service
ââ31540 /usr/bin/uwsgi --ini /etc/uwsgi/emperor.ini
Feb 02 04:37:04 MyMachine uwsgi[31540]: [uWSGI] getting INI configuration from /etc/uwsgi/emperor.ini
Feb 02 04:37:04 MyMachine systemd[1]: Started uWSGI Emperor.
That bit right there? "The Emperor is governing 0 vassals" for some reason it will not look at the myapp.ini in the vassal directory. This is what I get in a command line "log":
*** Starting uWSGI 2.0 (64bit) on [Sun Feb 2 05:27:37 2014] ***
compiled with version: 4.8.2 20131219 (prerelease) on 09 January 2014 11:43:55
os: Linux-3.12.7-2-ARCH #1 SMP PREEMPT Sun Jan 12 13:09:09 CET 2014
nodename: MyMachine
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /home/me
detected binary path: /usr/bin/uwsgi
your processes number limit is 26743
your memory page size is 4096 bytes
*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
Python version: 2.7.6 (default, Nov 26 2013, 12:52:49) [GCC 4.8.2]
Python main interpreter initialized at 0xcfd340
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 415280 bytes (405 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0xcfd340 pid: 32089 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 32089)
spawned uWSGI worker 1 (pid: 32092, cores: 2)
spawned 2 offload threads for uWSGI worker 1
spawned uWSGI worker 2 (pid: 32095, cores: 2)
spawned uWSGI worker 3 (pid: 32097, cores: 2)
spawned 2 offload threads for uWSGI worker 3
spawned uWSGI worker 4 (pid: 32100, cores: 2)
spawned 2 offload threads for uWSGI worker 2
spawned 2 offload threads for uWSGI worker 4
I cannot seem to get uwsgi to run see its vassals no matter what I do. Thanks.
EDIT
OK so I decided to go back to the command line so I don't have to deal with log and pid permission errors and I noticed something strange. When I make write out uwsgi --ini /etc/uwsgi/emperor.ini the entire thing works, I can access the site through nginx, beautiful, but I saw this in the console output:
*** Starting uWSGI 2.0 (64bit) on [Sun Feb 2 15:19:43 2014] ***
compiled with version: 4.8.2 20131219 (prerelease) on 09 January 2014 11:43:55
os: Linux-3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014
nodename: MyMachine
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /home/me
detected binary path: /usr/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 26743
your memory page size is 4096 bytes
detected max file descriptor number: 1024
*** starting uWSGI Emperor ***
*** has_emperor mode detected (fd: 5) ***
[uWSGI] getting INI configuration from /etc/uwsgi/emperor.ini
*** Starting uWSGI 2.0 (64bit) on [Sun Feb 2 15:19:43 2014] ***
compiled with version: 4.8.2 20131219 (prerelease) on 09 January 2014 11:43:55
os: Linux-3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014
nodename: MyMachine
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /home/me
detected binary path: /usr/bin/uwsgi
your processes number limit is 26743
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
*** starting uWSGI sub-Emperor ***
Python version: 2.7.6 (default, Nov 26 2013, 12:52:49) [GCC 4.8.2]
*** has_emperor mode detected (fd: 7) ***
[uWSGI] getting INI configuration from myapp.ini
*** Starting uWSGI 2.0 (64bit) on [Sun Feb 2 15:19:43 2014] ***
compiled with version: 4.8.2 20131219 (prerelease) on 09 January 2014 11:43:55
os: Linux-3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014
nodename: MyMachine
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/bin/uwsgi
your processes number limit is 26743
your memory page size is 4096 bytes
*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
Python version: 2.7.6 (default, Nov 26 2013, 12:52:49) [GCC 4.8.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x2403ab0
your mercy for graceful operations on workers is 60 seconds
*** Operational MODE: no-workers ***
spawned uWSGI master process (pid: 1640)
Sun Feb 2 15:19:43 2014 - [emperor] vassal /etc/uwsgi/emperor.ini has been spawned
Python main interpreter initialized at 0x17682a0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 415280 bytes (405 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x17682a0 pid: 1642 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1642)
Sun Feb 2 15:19:45 2014 - [emperor] vassal myapp.ini has been spawned
spawned uWSGI worker 1 (pid: 1645, cores: 2)
spawned 2 offload threads for uWSGI worker 1
spawned uWSGI worker 2 (pid: 1648, cores: 2)
Sun Feb 2 15:19:45 2014 - [emperor] vassal myapp.ini is ready to accept requests
spawned 2 offload threads for uWSGI worker 2
spawned uWSGI worker 3 (pid: 1651, cores: 2)
spawned 2 offload threads for uWSGI worker 3
spawned uWSGI worker 4 (pid: 1657, cores: 2)
*** Stats server enabled on 127.0.0.1:9191 fd: 16 ***
spawned 2 offload threads for uWSGI worker 4
[pid: 1648|app: 0|req: 1/1] 192.168.1.156 () {40 vars in 795 bytes} [Sun Feb 2 15:20:40 2014] GET /articles => generated 2943 bytes in 164 msecs (HTTP/1.1 200) 3 headers in 283 bytes (1 switches on core 0)
announcing my loyalty to the Emperor...
Sun Feb 2 15:20:40 2014 - [emperor] vassal myapp.ini is now loyal
[pid: 1657|app: 0|req: 1/2] 192.168.1.156 () {40 vars in 792 bytes} [Sun Feb 2 15:20:41 2014] GET /index => generated 3216 bytes in 184 msecs (HTTP/1.1 200) 3 headers in 283 bytes (1 switches on core 0)
announcing my loyalty to the Emperor...
Sun Feb 2 15:20:42 2014 - [emperor] vassal myapp.ini is now loyal
I started noticing some odd ball behavior in the output. I finally came down to this configuration which let's me see my site.
emperor.ini
[uwsgi]
emperor = /etc/uwsgi/vassals
master = true
#gid = http
#uid = http
I commented out the gid and uid because with them there I get a bad gateway response when I try to connect to my website, it warns me about it in the log uWSGI running as root, you can use --uid/--gid/--chroot options but I am not sure what to do about it.
myapp.ini
[uwsgi]
chdir = /srv/http/myapp/src/
wsgi-file = run.py
callable = app
processes = 4
threads = 2
offload-threads = 2
stats = 127.0.0.1:9191
max-requests = 5000
master = true
vacuum = true
socket = 127.0.0.1:3031
harakiri = 60
uwsgi.service
[Unit]
Description=uWSGI Emperor
After=syslog.target
[Service]
ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi/emperor.ini --enable-threads
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=main
[Install]
WantedBy=multi-user.target
No idea what to do about it running as root.
create a vassals in /etc/uwsgi/vassals/

Resources