uWSGI

最後更新: 2017-01-02

目錄

uwsgi 介紹
    Components & Package
    uwsgi Install & testing
nginx 設定
    file: uwsgi_params
    Cluster App Server
    Dynamic apps
    Static files
    uwsgi protocol magic variables
Automatically starting uWSGI on boot
    Default configure
    Start / Stop Script
parses uwsgi configure files
    Expanding variables
    Placeholders
    ‘@’ magic
    Magic variables
    Fallback configuration
    Configuration logic
Router
uwsgi Protocol
Signals for controlling uWSGI
Logging
webpy
DOC

  • mod_wsgi 介紹
  • mod_wsgi 設定
  • py Code
  • Sessions
  • Daemon mode
  • DOC

 

 


Web Server connect Script 方式

 

cgi (one new process per request) [PUT / POST + Env Var ==>  standard input ]

mod_python (Apache module)

fcgi (FastCGI uses persistent processes to handle a series of requests)

運作:

mod_fastcgi(Apache) acts as a FCGI client

wsgi (Web Server Gateway Interface){mod_wsgi}[Python - low-level interface ]

運作:

server -- env info +  callback function --> py
server  <-- HTTP headers + content -- py framework

http://datahunter.org/apache_with_python

uwsgi

A full stack for building hosting services (apps, proxies, pm mon)

 


uWSGI 介紹

 

A full stack for building hosting services (apps, proxies, pm mon)

Application servers (for various programming languages and protocols), proxies, process managers and monitors

are all implemented using a common api and a common configuration style.

HomePage: http://projects.unbit.it/uwsgi/

 


Components & Package

 

Components:

- Core
  + configuration
  + processes management
  + sockets creation
  + monitoring
  + logging
  + shared memory areas
  + ipc
  + cluster membership

- Request plugins (application server interfaces for various languages)(platforms: WSGI, PSGI, Rack, Lua WSAPI, CGI, PHP, Go ...)
- Gateways (implement load balancers, proxies and routers)
- Emperor (massive instances management and monitoring)
- Loop engines (events and concurrency, components can be run in preforking, threaded, asynchronous/evented)

Package:

main:

uwsgi                            # fast, self-healing application container server

uwsgi-plugin-python      # Python via uWSGI

other plugin:

uwsgi-plugin-cache
uwsgi-plugin-nagios
uwsgi-plugin-echo
uwsgi-plugin-admin

admin_plugin.so
/usr/bin/uwsgi_admin (pure C)
man uwsgi_admin

uwsgi-plugin-cache
...............

 


uwsgi Install & testing

 

uwsgi Install:

apt-get install uwsgi uwsgi-plugin-python

uwsgi --version

1.2.3-debian

uwsgi testing:

foobar.py

def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return ["Hello World"]

# 如果不 listen tcp port, 就可以用 –http-socket 取代 --http

uwsgi_python  --http :9090  --wsgi-file foobar.py

output:

[uwsgi] implicit plugin requested python
*** Starting uWSGI 1.2.3-debian (32bit) on [Fri Jan  2 17:54:13 2015] ***
compiled with version: 4.7.2 on 08 July 2013 03:16:01
detected number of CPU cores: 1
current working directory: /home/tim/uwsgi
detected binary path: /usr/bin/uwsgi-core
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uwsgi socket 0 bound to TCP address :9090 fd 3
Python version: 2.7.3 (default, Mar 14 2014, 12:14:27)  [GCC 4.7.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x88f1b38
your server socket listen backlog is limited to 100 connections
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x88f1b38 pid: 15788 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 15788, cores: 1)

當有 access 時:

[pid: 15788|app: 0|req: 3/3] 192.168.123.200 () {32 vars in 588 bytes} 
[Fri Jan  2 17:56:22 2015] GET / => generated 11 bytes in 0 msecs (HTTP/1.1 200) 
1 headers in 44 bytes (1 switches on core 0)

P.S.

uwsgi_python 才有 --wsgi-file  (package: uwsgi-plugin-python)

/usr/bin/uwsgi_python -> /etc/alternatives/uwsgi_python


Processes & Threads

# This will spawn 4 processes (each with 2 threads),

# A master process (will respawn your processes when they die) and the HTTP router

uwsgi_python --http :9090 --wsgi-file foobar.py --master --processes 4 --threads 2

P.S.

If you start uWSGI without threads, the Python GIL will not be enabled

# Export uWSGI’s internal statistics as JSON

uwsgi ... --stats 127.0.0.1:9191

OR

uwsgi ... --stats /tmp/statsock

# 查看 result (json 來)

nc 127.0.0.1 9191

# 查看 status - uwsgitop

pip install uwsgitop

uwsgitop

# Loading configuration files

uwsgi --ini http://uwsgi.it/configs/myapp.ini # HTTP
uwsgi --xml - # standard input
uwsgi --yaml fd://0 # file descriptor
uwsgi --json 'exec://nc 192.168.11.2:33000' # arbitrary executable

# 其他有用的 opts

# limit processes address space/vsz (unit: Mbyte)

--limit-as 128

#  daemonize uWSGI

-d|--daemonize


nginx 設定

 

main configure (one uwsgi one website)

server {
  # Change this if you want to serve your application on another port
  listen 80;

  # Replace this with your domain name
  server_name apps.example.com;
 
  # You can use virtual directory like '/apps/' here, but remember that
  # you should matching 'urls' defined in your web.py application file
  location / {
    include uwsgi_params;
 
    # This should match the 'socket' entry of your uwsgi.xml
    uwsgi_pass 127.0.0.1:9090;
 

    # 由於採用獨立的 uwsgi instanse, 所以不用設定 UWSGI_CHDIR 及 UWSGI_SCRIPT

    # This is the absolute path to the folder containing your application
    # chdir() to the specified directory before managing the request.
    #uwsgi_param UWSGI_CHDIR /var/www/apps;

    # This is the name of your application file, minus the '.py' extension
    # uWSGI can be launched without passing it any application configuration
    #uwsgi_param UWSGI_SCRIPT index;
  }
}

file: uwsgi_params

uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_ADDR $server_addr;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;

Static files

location /media {
  alias /var/lib/python-support/python2.6/django/contrib/admin/media;
}

if (!-f $request_filename) {
  uwsgi_pass uwsgicluster;
}

 


Automatically starting uWSGI on boot

 

/etc/uwsgi/apps-available/myapp.ini

[uwsgi]
logto = /var/log/uwsgi/test.log

#socket = /tmp/test.socket
socket = 127.0.0.1:9090

gid = www-data
uid = www-data

#vhost = true
#plugins-dir = <path_to_your_plugin_directory>
#plugins = python

# 當 nginx 沒有指定 "UWSGI_CHDIR" 及 "UWSGI_SCRIPT" 時, 那就要在這 ini 設定它
chdir = /var/www/apps/
wsgi-file = index.py

processes = 4
threads = 2

stats = 127.0.0.1:9191

log

Mon Apr 20 17:54:33 2015 - WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x8b01800 pid: 27296 (default app)
Mon Apr 20 17:54:33 2015 - *** uWSGI is running in multiple interpreter mode ***

Default configure:

# try to autoload appropriate plugin
autoload = true

master = true

workers = 2

# automatically kill workers on master's death
no-orphans = true

# bind to UNIX socket at /run/uwsgi/<confnamespace>/<confname>/socket
socket = /run/uwsgi/%(deb-confnamespace)/%(deb-confname)/socket

# set mode of created UNIX socket
chmod-socket = 660

# place timestamps into log
log-date = true

# identifier of uWSGI processes
uid = www-data
gid = www-data

Start / Stop Script

/etc/init.d/uwsgi

它會載入 /etc/default/uwsgi

RUN_AT_STARTUP=yes

VERBOSE=yes

# # Should init.d script print configuration file names while marking progress of it's execution
PRINT_CONFNAMES_IN_INITD_SCRIPT_OUTPUT=no

# inherited configuration file
INHERITED_CONFIG=/usr/share/uwsgi/conf/default.ini

 

每一個 app 的設定在放在此兩個 folder

/etc/uwsgi/apps-available

/etc/uwsgi/apps-enabled

P.S.

uwsgi yourfile.ini

 


Cluster App Server 設定 (Nginx)

 

 uwsgi_pass 127.0.0.1:9090;

改成

upstream uwsgicluster {
  server unix:///tmp/uwsgi.sock;
  server 192.168.1.235:3031;
  server 10.0.0.17:3017;
  ..........
}

server {
  ..........
  location / {
    ..........
    uwsgi_pass uwsgicluster;
  }
}

uwsgi protocol magic variables

 

Nginx:

uwsgi_param <name> <value>

# http | https

UWSGI_SCHEME

# Load the specified script as a new application

UWSGI_SCRIPT

# Dynamically set the Python Virtualenv support

UWSGI_PYHOME

# chdir() to the specified directory before managing the request.

UWSGI_CHDIR

# Set the specified environment variable for a new dynamic app.

UWSGI_SETENV

uwsgi_param UWSGI_SETENV DJANGO_SETTINGS_MODULE=myapp.settings;

# Check the uWSGI cache for a specified key.
# If the value is found, it will be returned as raw HTTP output instead of the usual processing of the request.

UWSGI_CACHE_GET

uwsgi_param UWSGI_CACHE_GET $request_uri;

 


parses uwsgi configure files

 

- top-bottom and expand asap

Expanding variables

# $(PATH)
foobar = $(PATH)

Placeholders

[uwsgi]
foo = 17
bar = 30
; total will be 50
total = %(foo + bar + 3)

‘@’ magic

# expand text files embraced in @(FILENAME)
nodename = @(/etc/hostname)

Magic variables

%n     the filename without extension

i.e.

[uwsgi]
socket = /tmp/%n.sock
module = werkzeug.testapp:test_app
processes = 4
master = 1

–strict

You can easily add non-existent options to your config files (as placeholders, custom options, or app-related configuration items).

This is a really handy feature, but can lead to headaches on typos.

The strict mode (–strict) will disable this feature, and only valid uWSGI options are tolerated.

Fallback configuration

uwsgi --fallback-config safe.ini --uid 1000 --http-socket :80

Configuration logic

(for)

[uwsgi]
master = true
; iterate over a list of ports
for = 3031 3032 3033 3034 3035
# %(_) to the current iterated value
socket = 127.0.0.1:%(_)
endfor =
module = helloworld

(if-exists)

[uwsgi]
http = :9090
; redirect all requests if a file exists
if-exists = /tmp/maintainance.txt
route = .* redirect:/offline
endif =

(if-env)

[uwsgi]
if-env = PATH
print = Your path is %(_)
check-static = /var/www
endif =
socket = :3031

 


uwsgi Protocol (binary protocol)

 

4 bytes of a uwsgi packet describe the type of the data contained by the packet

 


Signals for controlling uWSGI

 

SIGHUP       gracefully reload all the workers and the master process (–reload)

SIGTERM     brutally reload all the workers and the master process     
                   (use –die-on-term to respect the convention of shutting down the instance)

SIGINT        immediately kill the entire uWSGI stack     (–stop)

Example:

uwsgi –reload /tmp/project-master.pid

OR

kill -HUP `cat /tmp/project-master.pid`

* When running with the master process mode,
  the uWSGI server can be gracefully restarted without closing the main sockets.


Logging

 

./uwsgi -s :3031 -w simple_app --daemonize /tmp/mylog.log

OR

./uwsgi -s :3031 -w simple_app --logto /tmp/mylog.log

OR

# UDP logging (logs to another machine to offload disk I/O)

./uwsgi -s :3031 -w simple_app --logto 192.168.0.100:1717

OR

# log to an unconnected UNIX socket

uwsgi --socket :3031 --logger socket:/tmp/uwsgi.logsock

OR

# syslog

uwsgi --socket :3031 --logger syslog:uwsgi1234

OR

# remote syslog

uwsgi --socket :3031 --logger rsyslog:12.34.56.78:12345,uwsgi1234

 

log rotate

/etc/logrotate.d/uwsgi

"/var/log/uwsgi/*.log" "/var/log/uwsgi/*/*.log" {
  copytruncate
  daily
  rotate 5
  compress
  delaycompress
  missingok
  notifempty
}

 


webpy (VirtualHosting mode)

 

webpy 的 Code:

#!/usr/bin/env python

import web

urls = (
        "/", "index",
)

class index:
        def GET(self):
                return "Test OK"

app = web.application(urls, globals(), autoreload=True)

if ( __name__ == "__main__" ):
        app.run()
else:
        application = app.wsgifunc()

"application =" 係一定要加的 !!

 

Server Setting

uwsgi: /etc/uwsgi/apps-enabled/webpy.ini

[uwsgi]
socket = 127.0.0.1:9090

processes = 4
threads = 2

vhost = true

plugins-dir = /usr/lib/uwsgi/plugins/
plugin = python27

stats = 127.0.0.1:9191

service uwsgi restart

ps aux | grep uwsgi

www-data 22109  0.0  0.3   9204  1588 ?        S    16:00   0:00 
/usr/bin/uwsgi --ini /usr/share/uwsgi/conf/default.ini
--ini /etc/uwsgi/apps-enabled/webpy.ini --daemonize /var/log/uwsgi/app/webpy.log

/var/log/uwsgi/app/webpy.log

Mon Apr 20 17:28:47 2015 - *** Starting uWSGI 1.2.3-debian (32bit) on [Mon Apr 20 17:28:47 2015] ***
Mon Apr 20 17:28:47 2015 - compiled with version: 4.7.2 on 08 July 2013 03:16:01
Mon Apr 20 17:28:47 2015 - detected number of CPU cores: 1
Mon Apr 20 17:28:47 2015 - current working directory: /
Mon Apr 20 17:28:47 2015 - writing pidfile to /run/uwsgi/app/webpy/pid
Mon Apr 20 17:28:47 2015 - detected binary path: /usr/bin/uwsgi-core
Mon Apr 20 17:28:47 2015 - setgid() to 33
Mon Apr 20 17:28:47 2015 - setuid() to 33
Mon Apr 20 17:28:47 2015 - your memory page size is 4096 bytes
Mon Apr 20 17:28:47 2015 - detected max file descriptor number: 1024
Mon Apr 20 17:28:47 2015 - allocated 1384 bytes (1 KB) for 2 cores per worker.
Mon Apr 20 17:28:47 2015 - VirtualHosting mode enabled.
Mon Apr 20 17:28:47 2015 - lock engine: pthread robust mutexes
Mon Apr 20 17:28:47 2015 - uwsgi socket 0 bound to UNIX address /run/uwsgi/app/webpy/socket fd 3
Mon Apr 20 17:28:47 2015 - uwsgi socket 1 bound to TCP address 127.0.0.1:9090 fd 5
Mon Apr 20 17:28:47 2015 - Python version: 2.7.3 (default, Mar 14 2014, 12:14:27)  [GCC 4.7.2]
Mon Apr 20 17:28:47 2015 - Python main interpreter initialized at 0x80b9138
Mon Apr 20 17:28:47 2015 - threads support enabled
Mon Apr 20 17:28:47 2015 - your server socket listen backlog is limited to 100 connections
Mon Apr 20 17:28:47 2015 - *** Operational MODE: preforking+threaded ***
Mon Apr 20 17:28:47 2015 - *** no app loaded. going in full dynamic mode ***
Mon Apr 20 17:28:47 2015 - *** uWSGI is running in multiple interpreter mode ***
Mon Apr 20 17:28:47 2015 - spawned uWSGI master process (pid: 25908)
Mon Apr 20 17:28:47 2015 - spawned uWSGI worker 1 (pid: 25914, cores: 2)
Mon Apr 20 17:28:47 2015 - spawned uWSGI worker 2 (pid: 25915, cores: 2)
Mon Apr 20 17:28:47 2015 - spawned uWSGI worker 3 (pid: 25916, cores: 2)
Mon Apr 20 17:28:47 2015 - spawned uWSGI worker 4 (pid: 25917, cores: 2)
Mon Apr 20 17:28:47 2015 - *** Stats server enabled on 127.0.0.1:9191 fd: 17 ***

nginx: /etc/nginx/sites-enabled/webpy

server {
  listen 80;
  server_name webpy.local;
  location / {
    include uwsgi_params;
    uwsgi_pass 127.0.0.1:9090;

    # (Dynamic apps)
    # Load the specified script as a new application mapped to SCRIPT_NAME.
    # The app will obviously only be loaded once, not on each request.
    uwsgi_param UWSGI_CHDIR /home/tim/cms;
    uwsgi_param UWSGI_SCRIPT code;

  }
}

service nginx restart

 


進階使用

 

UWSGI_TOUCH_RELOAD

location / {
  include uwsgi_params;
  uwsgi_param UWSGI_TOUCH_RELOAD /tmp/touchme.foo;
  uwsgi_pass /tmp/uwsgi.sock;
}

UWSGI_PYHOME

Dynamically set the Python Virtualenv support for a dynamic application

SCRIPT_NAME

the variable used to select a specific application. Hosting multiple apps in the same process

SCRIPT_NAME is the variable used to select a specific application.

 


Router

 

Embedded mode:

# spawn a HTTP server on port 8080 that forwards requests to a pool of 4 uWSGI workers

./uwsgi --master --http 127.0.0.1:8080 --module mywsgiapp --processes 4

Standalone mode:

# This will spawn a HTTP router that will forward requests to the uwsgi socket

./uwsgi --master --http 127.0.0.1:8080 --http-to /tmp/uwsgi.sock

 


Troubleshoot

 

<1> log: Mon Apr 20 17:05:38 2015 - -- unavailable modifier requested: 0 --

解決:

apt-get install uwsgi-plugin-python

/usr/bin/uwsgi_python27
/usr/bin/uwsgi_python26

/usr/lib/uwsgi/plugins/python26_plugin.so
/usr/lib/uwsgi/plugins/python27_plugin.so

/etc/uwsgi/apps-enabled/webpy.ini

# support multiple Python versions without building a binary for each one.
# multiple Python versions for the same uWSGI binary
plugins-dir = /usr/lib/uwsgi/plugins/
plugin = python27

<2> unable to load app 0 (mountpoint='') (callable not found or import error)

/etc/uwsgi/apps-enabled/webpy.ini

[uwsgi]
...
vhost = true

/etc/nginx/sites-enabled/webpy

server {
  ...
  location / {
    ...
    include uwsgi_params;
    uwsgi_pass 127.0.0.1:9090;
    uwsgi_param UWSGI_CHDIR /home/tim/cms;
    uwsgi_param UWSGI_SCRIPT code;
  }
}

 


 

介紹

 

wsgi (Web Server Gateway Interface)

mod_wsgi (http://code.google.com/p/modwsgi/)

它與 CGI 有差不多的功能

mod_wsgi 支援常見的兩種 Apache Mode

* single threaded 'prefork'
* multithreaded 'worker'

Performance

written in C code directly against the internal Apache and Python

mod_wsgi 有兩個 mode 行 python

Embedded (similar way to mod_python)(technically perform better)
     within the context of the normal Apache child processes

Daemon ( FASTCGI/SCGI solutions ) (generally be the safest)
    distinct user ensuring that WSGI applications cannot interfere with each other

Python 標準

standard interface between web servers and Python web applications or frameworks:

http://www.python.org/dev/peps/pep-0333/

新的標準是  PEP 3333

 


Load module

 

/etc/httpd/conf.d/wsgi.conf

LoadModule wsgi_module modules/mod_wsgi.so

 


行 py script

 

設定檔: mywebsite.conf

WSGISocketPrefix /var/run/wsgi
WSGIDaemonProcess mailpanel user=mailpaneluser
WSGIProcessGroup mailpanel

AddType text/html .py

..................

方法1: File 內 SetHandler

<Files code.py>
    SetHandler wsgi-script
    Options ExecCGI FollowSymLinks
</Files>

方法2: Directory 內 SetHandler

<Directory /var/www/iredadmin/>
    Order allow,deny
    Allow from all
    SetHandler wsgi-script
    Options ExecCGI
</Directory>

方法3: WSGIScriptAlias

it marks the target directory as containing WSGI scripts, or marks the specific file-path as a script,

that should be processed by mod_wsgi's wsgi-script handler.

http://www.example.com/wsgi/scriptname => /home/web/wsgi/scriptname

WSGIScriptAlias  /wsgi/ /home/web/wsgi/

相當於

Alias /wsgi/ /home/web/wsgi/
<Location /wsgi-scripts>
  SetHandler wsgi-script
  Options +ExecCGI
</Location>

P.S.

WSGIScriptAlias /wsgi/ /usr/local/wsgi/scripts/

!! 不同於 !!

WSGIScriptAlias /wsgi/ /usr/local/wsgi/scripts

 

方式4: WSGIScriptAliasMatch

WSGIScriptAliasMatch ^/wsgi/([^/]+) /usr/local/wsgi/scripts/$1.wsgi

 


py Code

 

app = web.application(urls, globals(), autoreload=False)
application = app.wsgifunc()

有問題時

# get an "ImportError: No module named web"

解決

import sys, os
abspath = os.path.dirname(__file__)
sys.path.append(abspath)
os.chdir(abspath)
import web

 

Accessible at 'http://x' instead of 'http://x/code.py/'

.htaccess

<IfModule mod_rewrite.c>      
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_URI} !^/icons
  RewriteCond %{REQUEST_URI} !^/favicon.ico$
  RewriteCond %{REQUEST_URI} !^(/.*)+code.py/
  RewriteRule ^(.*)$ code.py/$1 [PT]
</IfModule>

* If the code.py is in the subfolder myapp/, adjust the RewriteBase to RewriteBase /myapp/

 


Webpy 的 Sessions

 

app = web.application(urls, globals())
curdir = os.path.dirname(__file__)
session = web.session.Session(app, web.session.DiskStore(os.path.join(curdir,'sessions')),)
application = app.wsgifunc()

 


Daemon mode

 

WSGISocketPrefix

Each application can be delegated to its own dedicated daemon process running just the WSGI application

WSGISocketPrefix /var/run/wsgi

# Defines the directory and name prefix to be used for the UNIX domain sockets used by mod_wsgi
# to communicate between the Apache child processes and the daemon processes.
# 會自動建立 wsgi.12547.0.1.sock

WSGIDaemonProcess

WSGIDaemonProcess process_group_name user=tim threads=15 maximum-requests=3600 inactivity-timeout=3600 home=/home/tim/web

# name:                        # name of the daemon process group must be unique for the whole server
                                         (not possible to use the same daemon process group name in different virtual hosts)

# user:                          # If this option is not supplied the daemon processes will be run as the same user that Apache would run child processes

# group=name

# processes:                 # If not defined then only one process will be run in this process group.

# threads:                     # default will be to create 15 threads in each daemon process within the process group

# "maximum-requests"  # default: 0 . number of requests a daemon process should process before it is shutdown and restarted

# "inactivity-timeout"      # number of seconds allowed to pass before the daemon process is shutdown and restarted
                                      # when the daemon process has entered an idle state.

# "home"                       # Defines an absolute path of a directory which should be used as the initial current working directory of the daemon processes

# python-path=directory  # List of colon separated directories to add to the Python module search path

# stack-size=nnn             # Linux: 8MB (quite excessive)
                                           The amount of virtual memory in bytes to be allocated for the stack corresponding to each thread
                                           created by mod_wsgi in a daemon process.
 

WSGIProcessGroup

WSGIProcessGroup process_group_name

# specify which process group a WSGI application will be executed in

# If WSGIProcessGroup is not used, the application will be run within the standard Apache child processes.

Testing

ps aux | grep httpd

tim      12757  7.6  4.0 228040 20332 ?        Sl   16:11   0:04 /usr/sbin/httpd

 


Auto Reload

 

WSGIScriptReloading

Enable/Disable detection of WSGI script file changes.

Default: On

 


Other Options

 

WSGIPythonHome

Description:     Absolute path to Python prefix/exec_prefix directories.

WSGIPythonPath

Description:     Additional directories to search for Python modules.

WSGIPythonOptimize

Description:     Enables basic Python optimisation features.

# 0 - The default => no optimisations are applied

# 1 - basic optimisations (pyc(bytecode) to .pyo)

# 2 - doc strings will not be generated and thus not retained

pyo

pyo = optimized code

Python interpreter is invoked with the -O flag to generate

When a script is run by giving its name on the command line,

  the bytecode for the script is never written to a ‘.pyc’ or ‘.pyo’ file.

 


DOC

 


DOC

http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html