|Version 12 (modified by unbit, 2 years ago) (diff)|
Packaging the uWSGI server
Starting from version 0.9.7, the uWSGI platform is fully modular.
Packagers should try to split all the component in various packages.
The core profile in buildconf directory will build a uWSGI server without plugins.
This server will search for plugins in the current directory. This is not very practical for a distribution package, so the first step would be defining a plugin_dir in your build profile
[uwsgi] inherit = default plugin_dir = /usr/lib/uwsgi embedded_plugins = null
/usr/lib/uwsgi is a good choice for most of the os/system but feel free to change it to something better. Save the file to a new profile (buildconf/package.ini for example) and build it:
python uwsgiconfig --build package
(if you have not called the file package.ini change the --build argument)
Now we have the core server. Package it in a system path directory (/usr/bin is a good choice) and eventually add your init scripts.
Building the plugins
There are a lot of plugins available, you should make a package for each one.
The most useful example is the python one.
Python has different version available, and probably you would want to allow users to load the specific version on demand.
The objective is having all of these packages available:
uwsgi-plugin-python2.4 uwsgi-plugin-python2.5 uwsgi-plugin-python2.6 uwsgi-plugin-python2.7 uwsgi-plugin-python3.1 uwsgi-plugin-python3.2
Let's build each one
python2.4 uwsgiconfig --plugin plugins/python package python24 python2.5 uwsgiconfig --plugin plugins/python package python25 python2.6 uwsgiconfig --plugin plugins/python package python26 python2.7 uwsgiconfig --plugin plugins/python package python27 python2.7-dbg uwsgiconfig --plugin plugins/python package python27dbg python3.1 uwsgiconfig --plugin plugins/python package python31 python3.2 uwsgiconfig --plugin plugins/python package python32
Pay attention to the 'package' arg, it is the name of the build profile used for the core
The last arg will be the name of the plugin to generate (python27dbg will generate the python27dbg_plugin.so file)
Now in /usr/lib/uwsgi we will have the plugins. Put each one in the specific distro package
The standard way for loading uwsgi plugins is using the
directive (you can put it in configuration files, ldap entry or environment variables)
But there is a 'magic' way for loading plugins.
Make a series of symbolic links to the uwsgi binary
ln -s uwsgi uwsgi_python24 ln -s uwsgi uwsgi_python25 ln -s uwsgi uwsgi_python26 ln -s uwsgi uwsgi_python27 ln -s uwsgi uwsgi_python31 ln -s uwsgi uwsgi_python32
Calling one of those symbolic links will automatically load the specific plugin
You can even use the --autoload option that will try to automagically load plugins, basing the choice on the command line/config files parameters
Probably the best way for auto-starting apps is using the Emperor. It allows you to monitor directory for the presence of uWSGI config files and to automatically pass configuration parameters to all the instances.
An auto-deploy system could be based on the admin linking approved app config files in /etc/uwsgi.
The apps will be auto spawned if the emperor is running like this
uwsgi --emperor /etc/uwsgi
Feel free to experiment various way of startup scripts.