Tirex/Backends

From OpenStreetMap Wiki
Jump to: navigation, search
Available languages — Tirex/Backends
Afrikaans Alemannisch aragonés asturianu azərbaycanca Bahasa Indonesia Bahasa Melayu Bân-lâm-gú Basa Jawa Baso Minangkabau bosanski brezhoneg català čeština dansk Deutsch eesti English español Esperanto estremeñu euskara français Frysk Gaeilge Gàidhlig galego Hausa hrvatski Igbo interlingua Interlingue isiXhosa isiZulu íslenska italiano Kiswahili Kreyòl ayisyen kréyòl gwadloupéyen kurdî latviešu Lëtzebuergesch lietuvių magyar Malagasy Malti Nederlands Nedersaksies norsk norsk nynorsk occitan Oromoo oʻzbekcha/ўзбекча Plattdüütsch polski português português do Brasil română shqip slovenčina slovenščina Soomaaliga suomi svenska Tiếng Việt Türkçe Vahcuengh vèneto Wolof Yorùbá Zazaki српски / srpski беларуская български қазақша македонски монгол русский тоҷикӣ українська Ελληνικά Հայերեն ქართული नेपाली मराठी हिन्दी অসমীয়া বাংলা ਪੰਜਾਬੀ ગુજરાતી ଓଡ଼ିଆ தமிழ் తెలుగు ಕನ್ನಡ മലയാളം සිංහල ไทย မြန်မာဘာသာ ລາວ ភាសាខ្មែរ ⵜⴰⵎⴰⵣⵉⵖⵜ አማርኛ 한국어 日本語 中文(简体)‎ 吴语 粵語 中文(繁體)‎ ייִדיש עברית اردو العربية پښتو سنڌي فارسی ދިވެހިބަސް
The checkerboard test pattern created by the test backend.

Tirex can work with several (rendering) backends at the same time. Currently the following backends are available:

Mapnik
This backend will be used in most cases. It uses the Mapnik rendering engine to render tiles.
Test
This backend is used for testing your Tirex setup. It creates tiles in a checkerboard pattern.
WMS
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.

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.

Third-party backends