Starting from 1.1 certain logic constructs are available.
The following statements are currently supported:
Each of these statements exports a context value you can access with the special placeholder %(_) For example, the for statement sets %(_) to the current iterated value.
Warning
Recursive logic is not supported and will cause uWSGI to promptly exit.
Iterates over space-separated strings.
[uwsgi]
master = true
; iterate over a list of ports
for = 3031 3032 3033 3034 3035
socket = 127.0.0.1:%(_)
endfor =
module = helloworld
or equivalently
<uwsgi>
<master/>
<for>3031 3032 3033 3034 3035</for>
<socket>127.0.0.1:%(_)</socket>
<endfor/>
<module>helloworld</module>
</uwsgi>
or equivalently still
uwsgi --for="3031 3032 3033 3034 3035" --socket="127.0.0.1:%(_)" --endfor --module helloworld
Check if an environment variable is defined, putting its value in the context placeholder.
[uwsgi]
if-env = PATH
print = Your path is %(_)
check-static = /var/www
endif =
socket = :3031
Check for the existence of a file/directory. The context placeholder is set to the filename found.
[uwsgi]
http = :9090
; redirect all requests if a file exists
if-exists = /tmp/maintainance.txt
route = .* redirect:/offline
endif =
Note
The above example uses uWSGI internal routing.
Check if the given path exists and is a regular file. The context placeholder is set to the filename found.
<uwsgi>
<plugins>python</plugins>
<http-socket>:8080</http-socket>
<if-file>settings.py</if-file>
<module>django.core.handlers.wsgi:WSGIHandler()</module>
<endif/>
</uwsgi>
Check if the given path exists and is a directory. The context placeholder is set to the filename found.
uwsgi:
socket: 4040
processes: 2
if-file: config.ru
rack: %(_)
endif: