$ pacman -Syu nginx uwsgi-plugin-python uwsgi python2-flask sqlite
$ tree /srv/http
/srv/http
└── app
├── app.nginx.conf
├── app.uwsgi.ini
├── htdocs
│ └── flask_app.py
├── log
└── run
| server { | |
| listen 80; | |
| server_name localhost; | |
| root /srv/http/app/htdocs; | |
| error_log /srv/http/app/log/error.log; | |
| access_log /srv/http/app/log/access.log; | |
| location / { | |
| try_files $uri @context; | |
| } | |
| location @context { | |
| include uwsgi_params; | |
| uwsgi_pass unix:/srv/http/app/run/app.uwsgi.sock; | |
| } | |
| } |
| [uwsgi] | |
| # the python module to import | |
| module = flask_app | |
| # the variable the holds the flask context | |
| callable = app | |
| plugin = python2 | |
| master = True | |
| chdir = %dhtdocs | |
| socket = %drun/%n.sock | |
| pidfile = %drun/.pid | |
| logto = %dlog/%n.log | |
| uid = http | |
| gid = http |
| user http; | |
| worker_processes 1; | |
| events { | |
| worker_connections 1024; | |
| } | |
| http { | |
| include mime.types; | |
| default_type application/octet-stream; | |
| sendfile on; | |
| keepalive_timeout 65; | |
| gzip on; | |
| include /srv/http/*/*.nginx.conf; | |
| } |
| [Unit] | |
| Description=uWSGI Server | |
| [Service] | |
| ExecStart=/usr/bin/uwsgi --emperor "/srv/http/*/*.uwsgi.ini" --uid=http --gid=http | |
| SuccessExitStatus=30 | |
| ExecReload=/bin/kill -HUP $MAINPID | |
| KillSignal=SIGINT | |
| Restart=always | |
| Type=notify | |
| NotifyAccess=all | |
| [Install] | |
| WantedBy=multi-user.target |