Bjoern is a screamingly fast, ultra-lightweight asynchronous WSGI server that can be used to deploy your TurboGears application in a very simple and light-weight manner.
Note that the following documentation assumes you are using TurboGears 1.5.1 and CherryPy 3.2 or newer versions. We also assume that you are deploying on a Linux server, though this setup may be possible on other platforms as well.
Before installing bjoern, check if the
libev-devel package is installed
on your system, otherwise install it via the package manager. Installing
bjoern should then be as simple as:
pip install bjoern
We assume your TurboGears application is called
myapp. Then to serve
your application using bjoern, just run the following small Python script:
from bjoern import run from myapp import command application = command.start() run(application, '0.0.0.0', 80)
You can refine this script so that it can serve as a start script in
/etc/init.d, or run this script indirectly via supervisor.
For security reasons, the script should be run by a user with as little
privileges as necessary to run your application.
If you installed your TurboGears application in a virtual environment
(as recommended), you should put the above server script into the
subdirectory of your virtual environment, e.g. as
simply add the following line to the import statements in this script:
If you have set up your virtual environment using
bjoern as a global package, then add this line below the
from bjoern import run, otherwise add it above that line.