Uwsgi Documentation Release 1.9
Total Page:16
File Type:pdf, Size:1020Kb
uWSGI Documentation Release 1.9 uWSGI August 26, 2015 Contents 1 Included components (updated to latest stable release)3 2 Quickstarts 5 2.1 Quickstart for python/WSGI applications................................5 2.2 Quickstart for perl/PSGI applications.................................. 10 3 Table of Contents 17 3.1 Getting uWSGI.............................................. 17 3.2 Installing uWSGI............................................. 17 3.3 The uWSGI build system........................................ 18 3.4 Managing the uWSGI server....................................... 21 3.5 Supported languages and platforms................................... 24 3.6 Supported Platforms/Systems...................................... 24 3.7 Web server integration.......................................... 25 3.8 Frequently Asked Questions (FAQ)................................... 26 3.9 Things to know (best practices and “issues”).............................. 30 3.10 Configuring uWSGI........................................... 31 3.11 Configuration logic............................................ 36 3.12 How uWSGI parses config files..................................... 39 3.13 Configuration Options.......................................... 41 3.14 Defining new options for your instances................................. 128 3.15 How uWSGI parses config files..................................... 130 3.16 uwsgi protocol magic variables..................................... 132 3.17 The uwsgi Protocol............................................ 135 3.18 Managing external daemons/services with uWSGI (1.3.1)....................... 136 3.19 The Master FIFO............................................. 138 3.20 Socket activation with inetd/xinetd................................... 140 3.21 Running uWSGI via Upstart....................................... 140 3.22 SystemD................................................. 142 3.23 Embedding an application in uWSGI.................................. 143 3.24 Logging.................................................. 146 3.25 Formatting uWSGI requests logs.................................... 150 3.26 Log encoders............................................... 153 3.27 Hooks................................................... 156 3.28 Glossary................................................. 159 4 Tutorials 161 i 5 Articles 163 6 uWSGI Subsystems 165 6.1 The uWSGI alarm subsystem (from 1.3)................................ 165 6.2 The uWSGI caching framework..................................... 169 6.3 WebCaching framework......................................... 172 6.4 The uWSGI cron-like interface..................................... 173 6.5 The uWSGI FastRouter......................................... 176 6.6 uWSGI internal routing......................................... 180 6.7 The uWSGI Legion subsystem...................................... 193 6.8 Locks................................................... 197 6.9 uWSGI Mules.............................................. 197 6.10 The uWSGI offloading subsystem.................................... 199 6.11 The uWSGI queue framework...................................... 200 6.12 uWSGI RPC Stack............................................ 201 6.13 SharedArea – share data between workers................................ 204 6.14 The uWSGI Signal Framework..................................... 204 6.15 The uWSGI Spooler........................................... 207 6.16 uWSGI Subscription Server....................................... 208 6.17 Serving static files with uWSGI (updated to 1.9)............................ 211 6.18 SNI - Server Name Identification (virtual hosting for SSL nodes)................... 216 6.19 The GeoIP plugin............................................ 217 6.20 uWSGI Transformations......................................... 218 6.21 WebSocket supports........................................... 221 7 Scaling with uWSGI 225 7.1 The uWSGI cheaper subsystem – adaptive process spawning...................... 225 7.2 The uWSGI Emperor – multi-app deployment............................. 229 7.3 Auto-scaling with Broodlord mode................................... 239 7.4 Zerg mode................................................ 239 7.5 Adding applications dynamically.................................... 241 7.6 Scaling SSL connections (uWSGI 1.9)................................. 242 8 Securing uWSGI 247 8.1 Setting POSIX Capabilities....................................... 247 8.2 Running uWSGI in a Linux CGroup................................... 248 8.3 Using Linux KSM in uWSGI...................................... 249 8.4 Jailing your apps using Linux Namespaces............................... 250 8.5 FreeBSD Jails.............................................. 252 8.6 The Forkpty Router........................................... 256 9 Keeping an eye on your apps 259 9.1 Monitoring uWSGI with Nagios..................................... 259 9.2 The embedded SNMP server....................................... 259 9.3 Pushing statistics (from 1.4)....................................... 260 9.4 Integration with Graphite/Carbon.................................... 261 9.5 The uWSGI Stats Server......................................... 262 10 Async and loop engines 267 10.1 uWSGI asynchronous/nonblocking modes (updated to uWSGI 1.9).................. 267 10.2 The Gevent loop engine......................................... 270 11 Web Server support 273 11.1 Apache support.............................................. 273 11.2 Cherokee support............................................. 274 ii 11.3 Native HTTP support........................................... 275 11.4 HTTPS support (from 1.3)........................................ 278 11.5 The SPDY router (uWSGI 1.9)..................................... 279 11.6 Lighttpd support............................................. 280 11.7 Attaching uWSGI to Mongrel2..................................... 281 11.8 Nginx support.............................................. 283 12 Language support 287 12.1 Python support.............................................. 287 12.2 The PyPy plugin............................................. 306 12.3 Running PHP scripts in uWSGI..................................... 311 12.4 uWSGI Perl support (PSGI)....................................... 315 12.5 Ruby support............................................... 317 12.6 Using Lua/WSAPI with uWSGI..................................... 324 12.7 Integrating uWSGI with Erlang..................................... 326 12.8 JVM in the uWSGI server (updated to 1.9)............................... 330 12.9 The Mono ASP.NET plugin....................................... 333 12.10 Running CGI scripts on uWSGI..................................... 335 12.11 uWSGI Go support (1.4-dev)...................................... 339 12.12 The XSLT plugin............................................. 343 12.13 SSI (Server Side Includes) plugin.................................... 344 12.14 uWSGI V8 support............................................ 346 12.15 The GridFS plugin............................................ 347 12.16 The GlusterFS plugin.......................................... 351 12.17 The RADOS plugin........................................... 354 13 Release Notes 357 13.1 uWSGI 1.9.17.............................................. 357 13.2 uWSGI 1.9.16.............................................. 359 13.3 uWSGI 1.9.15.............................................. 362 13.4 uWSGI 1.9.14.............................................. 368 13.5 uWSGI 1.9.13.............................................. 371 13.6 uWSGI 1.9.12.............................................. 374 13.7 uWSGI 1.9.11.............................................. 378 13.8 uWSGI 1.9.10.............................................. 381 13.9 uWSGI 1.9.9............................................... 381 13.10 uWSGI 1.9.8............................................... 386 13.11 uWSGI 1.9.7............................................... 386 13.12 uWSGI 1.9.6............................................... 389 13.13 uWSGI 1.9.5............................................... 393 13.14 uWSGI 1.9.4............................................... 394 13.15 uWSGI 1.9.3............................................... 396 13.16 uWSGI 1.9.2............................................... 399 13.17 uWSGI 1.9.1............................................... 400 13.18 uWSGI 1.9................................................ 403 13.19 uWSGI 1.4.10 (LTS)........................................... 408 14 Contact 411 15 Donate 413 16 Indices and tables 415 Python Module Index 417 iii iv uWSGI Documentation, Release 1.9 The uWSGI project aims at developing a full stack for building (and hosting) clustered/distributed network applica- tions. Mainly targeted at the web and its standards, it has been successfully used in a lot of different contexts. Thanks to its pluggable architecture it can be extended without limits to support more platforms and languages. Cur- rently, you can write plugins in C, C++ and Objective-C. The “WSGI” part in the name is a tribute to the namesake Python standard, as it has been the first developed plugin for the project. Versatility, performance, low-resource usage and reliability are the strengths of the project (and the only rules fol- lowed). Contents 1 uWSGI Documentation, Release 1.9 2 Contents CHAPTER 1 Included components (updated to latest stable release)