Tirex can work with several (rendering) backends at the same time. Currently the following backends are available:
- This backend will be used in most cases. It uses the Mapnik rendering engine to render tiles.
- This backend is used for testing your Tirex setup. It creates tiles in a checkerboard pattern.
- This backend doesn't render the tiles itself, but gets the maps from a WMS server.
Also see Config for information on how to configure those backends. Tirex comes with a pre-configured test backend.
The backends are mostly independent from the rest of the Tirex system.
Backends can be written in any programming language. Test test and wms backends are written in Perl. See the code under Tirex::Backend and Tirex::Backend::Test for how it is done. The mapnik backend is written in C++, see the code in the backend-mapnik directory in subversion for the code.
Backends are started from the tirex-backend-manager. The manager sets the following environment variables to configure the backend:
|TIREX_BACKEND_NAME||The name of this backend.|
|TIREX_BACKEND_PORT||The UDP port number where the backend should listen for requests.|
|TIREX_BACKEND_SYSLOG_FACILITY||The syslog facility, the backend should log into.|
|TIREX_BACKEND_MAP_CONFIGS||A space separated list of config file names that the backend should read. Normally these are the files in /etc/tirex/renderer/renderer/*.conf|
|TIREX_BACKEND_ALIVE_TIMEOUT||The backend is expected to send an alive message into the pipe at least this often (seconds).|
|TIREX_BACKEND_PIPE_FILENO||The file descriptor of the pipe where the alive message should be send. The pipe will be opened by the manager and it is inherited by the backend.|
|TIREX_BACKEND_SOCKET_FILENO||The file descriptor of the UDP socket where the backend gets rendering requests from. The socket will be opened by the manager and it is inherited by the backend.|
|TIREX_BACKEND_DEBUG||If this is set the backend should go into debugging mode and do verbose logging into syslog.|
|TIREX_BACKEND_CFG_*||In addition to the environment variables above the backend will get environment variables for all config settings from its config file named after those config options. So the config option fontdir will appear in the environment variable TIREX_BACKEND_CFG_fontdir.|
Backends are expected to read the map configurations from the files named in TIREX_BACKEND_MAP_CONFIGS and configure themselves accordingly. They must be able to handle rendering requests for all those maps.
To make the Tirex system more robust when rendering backends fail, all backends are required to send alive messages to the manager. If the alive message doesn't appear in time, the manager will kill the backend and re-start it. The backend should send such an alive message every time it has finished rendering a metatile and, if it is idle, at least every TIREX_BACKEND_ALIVE_TIMEOUT seconds.
The backend will be given an open UDP socket on the file descriptor with number TIREX_BACKEND_SOCKET_FILENO. It must read rendering requests from this socket, create the metatile and reply to them. If TIREX_BACKEND_SOCKET_FILENO is not set, it should open the socket itself using port TIREX_BACKEND_PORT.