Contents

Backend interface

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.

Environment

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.

Map configuration

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.

Alive message

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.

Rendering requests

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.