diff --git a/Makefile b/Makefile index 453948d..a9608fa 100644 --- a/Makefile +++ b/Makefile @@ -61,8 +61,6 @@ install: build install -m 644 ${INSTALLOPTS} etc/renderer/mapserver/fonts.lst $(DESTDIR)/etc/tirex/renderer/mapserver/fonts.lst install -m 755 ${INSTALLOPTS} -d $(DESTDIR)/etc/tirex/renderer/mapnik install -m 644 ${INSTALLOPTS} etc/renderer/mapnik.conf.dist $(DESTDIR)/etc/tirex/renderer/mapnik.conf - install -m 755 ${INSTALLOPTS} -d $(DESTDIR)/etc/logrotate.d - install -m 644 ${INSTALLOPTS} etc/logrotate.d/tirex-master $(DESTDIR)/etc/logrotate.d/tirex-master install -m 755 ${INSTALLOPTS} -d $(DESTDIR)/usr/share/man/man1/ for program in bin/*; do \ if grep -q "=head" $$program; then \ diff --git a/README.md b/README.md index 53fd523..b37109a 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ installed. Call to create the packages. The following packages will be created in the parent directory: - tirex-core + tirex tirex-backend-mapnik tirex-backend-wms tirex-backend-mapserver diff --git a/backend-mapnik/metatilehandler.cc b/backend-mapnik/metatilehandler.cc index 83683c0..6977f74 100644 --- a/backend-mapnik/metatilehandler.cc +++ b/backend-mapnik/metatilehandler.cc @@ -25,7 +25,7 @@ #include #include #include -#include +#include #if MAPNIK_VERSION >= 300000 # include @@ -218,7 +218,15 @@ const NetworkResponse *MetatileHandler::handleRequest(const NetworkRequest *requ } outfile.close(); + free(offsets); delete rrs; + + if (outfile.fail()) + { + unlink(tmpfilename); + return NetworkResponse::makeErrorResponse(request, "cannot write metatile"); + } + rename(tmpfilename, metafilename); debug("created %s", metafilename); @@ -233,7 +241,6 @@ const NetworkResponse *MetatileHandler::handleRequest(const NetworkRequest *requ char buffer[20]; snprintf(buffer, 20, "%ld", (end.tv_sec-start.tv_sec) * 1000 + (end.tv_usec - start.tv_usec) / 1000); resp->setParam("render_time", buffer); - free(offsets); } debug("<< MetatileHandler::handleRequest"); return resp; diff --git a/backend-mapnik/networklistener.cc b/backend-mapnik/networklistener.cc index c032714..8e97093 100644 --- a/backend-mapnik/networklistener.cc +++ b/backend-mapnik/networklistener.cc @@ -193,7 +193,7 @@ void NetworkListener::run() if (mMaxRequests > -1 && ++mRequestCount > mMaxRequests) { error("maxrequests reached, terminating"); - exit(1); + break; } } } diff --git a/backend-mapnik/renderd.cc b/backend-mapnik/renderd.cc index 68c3df4..0822643 100644 --- a/backend-mapnik/renderd.cc +++ b/backend-mapnik/renderd.cc @@ -273,6 +273,6 @@ int main(int argc, char **argv) { RenderDaemon mtd(argc, argv); mtd.run(); - exit(9); // return with EXIT_CODE_RESTART==9 which means everything is ok, the backend can be restartet if the backend-manager wants to + exit(9); // return with EXIT_CODE_RESTART==9 which means everything is ok, the backend can be restarted if the backend-manager wants to } diff --git a/bin/tirex-backend-manager b/bin/tirex-backend-manager index 3d2ac76..a7aa3f1 100755 --- a/bin/tirex-backend-manager +++ b/bin/tirex-backend-manager @@ -141,6 +141,9 @@ my $TERM_TIMEOUT = 5; # timeout when waiting for alive messages from workers my $SELECT_TIMEOUT = 10; +# hash that catalogues worker processes +my $workers; + #----------------------------------------------------------------------------- # Main loop #----------------------------------------------------------------------------- @@ -148,7 +151,7 @@ my $SELECT_TIMEOUT = 10; my $sockets = {}; while (1) { - my $workers = {}; + $workers = {}; Tirex::Renderer->read_config_dir($config_dir); syslog('info', 'Found config for renderers: %s', join(' ', map { $_->get_name(); } Tirex::Renderer->all())); @@ -160,22 +163,15 @@ my $SELECT_TIMEOUT = 10; while (! $received_sighup) { - start_workers($workers, $sockets); - check_for_alive_messages($workers); - cleanup_dead_workers($workers); - kill_old_workers($workers); + start_workers($sockets); + check_for_alive_messages(); + cleanup_dead_workers(); + kill_old_workers(); if ($received_sigterm) { syslog('info', 'TERM/INT received, forwarding to children: %s', join(' ', keys %$workers)); - - foreach my $pid (keys %$workers) - { - kill('HUP', $pid); - } - - unlink($pidfile); # ignore return code - exit(0); + exit_gracefully(0); } sleep 1; @@ -192,6 +188,19 @@ my $SELECT_TIMEOUT = 10; } } +#----------------------------------------------------------------------------- +# Terminate and also kill all children. +#----------------------------------------------------------------------------- +sub exit_gracefully +{ + my $exitcode = shift; + foreach my $pid (keys %$workers) + { + kill('HUP', $pid); + } + unlink($pidfile); # ignore return code + exit($exitcode); +} #----------------------------------------------------------------------------- # Open sockets for all renderers or re-use old ones after a SIGHUP @@ -251,7 +260,6 @@ sub open_sockets #----------------------------------------------------------------------------- sub start_workers { - my $workers = shift; my $sockets = shift; foreach my $renderer (Tirex::Renderer->enabled()) @@ -327,8 +335,6 @@ sub create_pipe #----------------------------------------------------------------------------- sub check_for_alive_messages { - my $workers = shift; - my $select = IO::Select->new(); foreach my $worker (values %$workers) { @@ -353,33 +359,24 @@ sub check_for_alive_messages #----------------------------------------------------------------------------- sub cleanup_dead_workers { - my $workers = shift; - while ((my $pid = waitpid(-1, WNOHANG)) > 0) { - my $exit_code = $? >> 8; - my $signal = $? & 127; - syslog('warning', 'child %d terminated (exit_code=%d, signal=%d)', $pid, $exit_code, $signal); - # this will happen if a worker child dies which we don't know about # because we got a SIGHUP in between next unless ($workers->{$pid}); - # if the return code of the child is something other than $EXIT_CODE_RESTART, the renderer is disabled + my $exit_code = $? >> 8; + my $signal = $? & 127; + syslog('warning', 'child %d terminated (exit_code=%d, signal=%d)', $pid, $exit_code, $signal); + + # if the return code of the child is something other than $EXIT_CODE_RESTART, we quit. # this does not happen if the worker child was killed because of a timeout - #if ($exit_code != $Tirex::EXIT_CODE_RESTART && ! defined $workers->{$pid}->{'hungup'}) - #{ - # my $renderer = $workers->{$pid}->{'renderer'}; - # if ($renderer->get_debug()) - # { - # syslog('debug', 'renderer %s not disabled because we are in debug mode', $renderer->get_name()); - # } - # else - # { - # $renderer->disable(); - # syslog('err', 'disabled renderer %s', $renderer->get_name()); - # } - #} + if ($exit_code != $Tirex::EXIT_CODE_RESTART && ! defined $workers->{$pid}->{'hungup'}) + { + my $renderer = $workers->{$pid}->{'renderer'}; + syslog('err', 'terminating due to unexpected error in renderer %s', $renderer->get_name()); + exit_gracefully(2); + } $workers->{$pid}->{'handle'}->close(); $workers->{$pid}->{'renderer'}->remove_worker($pid); @@ -393,8 +390,6 @@ sub cleanup_dead_workers #----------------------------------------------------------------------------- sub kill_old_workers { - my $workers = shift; - my $now = time(); foreach my $worker (values %$workers) @@ -467,7 +462,6 @@ sub sigterm_handler $received_sigterm = 1; } - __END__ =head1 NAME diff --git a/bin/tirex-status b/bin/tirex-status index 287de78..065b13b 100755 --- a/bin/tirex-status +++ b/bin/tirex-status @@ -155,18 +155,22 @@ sub format_status my @styles = keys %{$d->{'rm'}->{'stats'}->{'sum_render_time'}}; my $maxzoom = 0; map { $maxzoom = max($maxzoom, scalar(@{$d->{'rm'}->{'stats'}->{'sum_render_time'}->{$_}})); } @styles; - $r = "style zoom |"; + my $max_name_len = 0; + map { $max_name_len = max($max_name_len, length($_)); } @styles; + + $r = "style" . " " x ($max_name_len-9) . "zoom |"; for (my $i = 0; $i < $maxzoom; $i++) { $r .= sprintf("%7d ", $i); } $r .= "\n"; - $r .= "---------------+"; - $r .= "----------" x $maxzoom; + $r .= "-" x $max_name_len; + $r .= "-+"; + $r .= "--------" x $maxzoom; $r .= "\n"; - foreach (@styles) + foreach (sort @styles) { - $r .= sprintf("%-15s|", $_); + $r .= sprintf("%-${max_name_len}s |", $_); for (my $i = 0; $i < $maxzoom; $i++) { my $time = $d->{'rm'}->{'stats'}->{'sum_render_time'}->{$_}->[$i]; diff --git a/debian/changelog b/debian/changelog index e3059b7..ff85189 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,116 +1,37 @@ -tirex (0.6.4) focal; urgency=medium - - * allow adding a dot and zoom level after mapfile parameter to override map file for specific zoom levels - - -- Frederik Ramm Fri, 13 Aug 2021 11:55:10 +0200 - -tirex (0.6.3) bionic; urgency=medium - - * modify TMS backend to take template URL parameter - - -- Frederik Ramm Mon, 29 Jun 2020 15:57:07 +0200 - -tirex (0.6.2) bionic; urgency=medium +tirex (0.8.0-pre) unstable; urgency=medium - * add TMS backend - - -- Frederik Ramm Wed, 21 Aug 2019 16:10:48 +0200 - -tirex (0.6.1) bionic; urgency=medium - - * add openseamap backend - - -- Frederik Ramm Wed, 21 Aug 2019 16:10:48 +0200 - -tirex (0.6.0) bionic; urgency=medium - - * tirex-syncd to use ssh master, also allow multiple destinations - - -- Frederik Ramm Sat, 02 Mar 2019 14:23:23 +0000 - -tirex (0.5.2) bionic; urgency=medium - - * die after serving X requests - - -- Frederik Ramm Mon, 14 Dec 2015 20:06:23 +0000 - -tirex (0.5.1) bionic; urgency=medium - - * jpeg tiles - * mapnik 3 - - -- Frederik Ramm Mon, 14 Dec 2015 20:06:23 +0000 - -tirex (0.4.1precise1) precise; urgency=low - - * support (alomst) arbitrary sized meta tiles - * support for Mapnik2 - - -- Frederik Ramm Tue, 26 Jun 2012 21:45:22 +0000 - -tirex (0.3.1debian1) precise; urgency=low - - * fix epsg3857 bug - - -- Frederik Ramm Tue, 08 May 2012 20:27:04 +0000 - -tirex (0.3.0) jaunty; urgency=low - - * add mapserver backend - - -- Sven Geggus Fri, 03 Feb 2012 19:43:24 +0100 - -tirex (0.2.0) jaunty; urgency=low - - * new renderd architecture allows several different renderers at the same time - * lots of other small improvements - - -- Frederik Ramm Mon, 3 May 2010 10:30:44 +0100 - -tirex (0.1.7) jaunty; urgency=low - - * bugfixes on zoom level 1+2 - - -- Frederik Ramm Mon, 15 Mar 2010 21:48:44 +0100 - -tirex (0.1.6) jaunty; urgency=low - - * munin plugin overhaul - - -- Frederik Ramm Fri, 26 Feb 2010 22:38:03 +0100 - -tirex (0.1.5) jaunty; urgency=low - - * new commands to stop/continue buckets - - -- Frederik Ramm Wed, 24 Feb 2010 15:03:40 +0100 - -tirex (0.1.4) jaunty; urgency=low - - * new features+utilities, manpages - - -- Frederik Ramm Thu, 18 Feb 2010 12:02:16 +0100 - -tirex (0.1.3) jaunty; urgency=low - - * lots of new features - - -- Frederik Ramm Mon, 15 Feb 2010 19:17:53 +0100 - -tirex (0.1.2) jaunty; urgency=low + * preliminary build for github HEAD - * fixed renderd starter dying + -- Frederik Ramm Thu, 19 May 2022 13:41:14 +0200 - -- Frederik Ramm Wed, 10 Feb 2010 17:15:52 +0100 +tirex (0.7.0-1) unstable; urgency=medium -tirex (0.1.1) jaunty; urgency=low + * Move from experimental to unstable. - * new build + -- Felix Delattre Mon, 22 Nov 2021 16:56:21 +0000 - -- Frederik Ramm Wed, 10 Feb 2010 11:40:21 +0100 +tirex (0.7.0-1~exp1) experimental; urgency=medium -tirex (0.1) unstable; urgency=low + [ Felix Delattre ] + * Initial package (Closes: #968676). + * New upstream release 0.7.0 + * Adjusted copyright information. + * Use tirex package. + * Sort and review dependencies. + * Review section declaration of packages. + * Place apache2 config when installing tirex. + * Introduce dedicated user _tirex. + * Remove experimental backends, plugins, and example map from packaging. + * Load utils into /usr/share. + * Handle tiles and stats in cache directory. + * Use daemon under /run. + * Check on systemd service files. + * Revisit configuration. + * Bump Standards-Version to 4.6.0, no changes. - * Initial release. + [ Bas Couwenberg ] + * Bump watch file version to 4. + * Bump Standards-Version to 4.5.1, no changes. + * Update watch file for GitHub URL changes. - -- Frederik Ramm Thu, 04 Feb 2010 00:57:52 +0100 + -- Felix Delattre Thu, 07 Oct 2021 14:37:41 +0000 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 7f8f011..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -7 diff --git a/debian/control b/debian/control index e8c578e..4c8468a 100644 --- a/debian/control +++ b/debian/control @@ -1,31 +1,59 @@ Source: tirex -Section: web -Priority: extra -Maintainer: Frederik Ramm -Build-Depends: debhelper (>= 7), libboost-program-options-dev, libmapnik-dev -Homepage: http://wiki.openstreetmap.org/wiki/Tirex -Standards-Version: 3.8.0 +Maintainer: Debian GIS Project +Uploaders: Felix Delattre +Section: science +Priority: optional +Build-Depends: debhelper-compat (= 12), + dh-apache2, + libboost-program-options-dev, + libipc-sharelite-perl, + libjson-perl, + libmapnik-dev +Standards-Version: 4.6.0 +Vcs-Browser: https://salsa.debian.org/debian-gis-team/tirex +Vcs-Git: https://salsa.debian.org/debian-gis-team/tirex.git +Homepage: https://wiki.openstreetmap.org/wiki/Tirex -Package: tirex-core +Package: tirex +Section: utils Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libjson-perl, libipc-sharelite-perl, libgd-gd2-perl, adduser -Provides: tirex-master -Suggests: libapache-mod-tile, tirex-backend-mapnik -Description: Core of the Tirex tile rendering system - The Tirex suite of programs manages map tile rendering and caching. - This package contains the master daemon, rendering manager, test backend, - and assorted utility programs. +Depends: adduser, + libapache2-mod-tile, + libgd-gd2-perl, + libjson-perl, + libipc-sharelite-perl, + ${misc:Depends}, + ${perl:Depends}, + ${shlibs:Depends} +Recommends: ${misc:Recommends} +Description: Daemon that renders raster map tile using different backends + Tirex consists of several tools to manage map raster tile rendering and + caching. It contains the master daemon, rendering manager, backends for + mapnik and testing, and assorted utility programs. + +Package: tirex-example-map +Section: web +Architecture: all +Depends: libjs-leaflet, + tirex, + ${misc:Depends}, +Recommends: ${misc:Recommends}, +Description: Tirex example map data and configuration + It comes with all connecting pieces to make tirex work + with Mapnik and Apache2 webserver. + After installation the map can be visisted in a web + browser by going to http://localhost/tirex-example-map. Package: tirex-munin-plugin Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, tirex-core, munin-node +Depends: ${shlibs:Depends}, ${misc:Depends}, tirex, munin-node Description: Munin plugin for the Tirex tile rendering system The Tirex suite of programs manages map tile rendering and caching. This package contains plugins that help to graph Tirex activity with Munin. Package: tirex-nagios-plugin Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, tirex-core +Depends: ${shlibs:Depends}, ${misc:Depends}, tirex Suggests: nagios3 | nagios-nrpe-server Description: Nagios plugins for the Tirex tile rendering system The Tirex suite of programs manages map tile rendering and caching. @@ -33,53 +61,38 @@ Description: Nagios plugins for the Tirex tile rendering system Package: tirex-backend-wms Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, tirex-core, libwww-perl +Depends: ${shlibs:Depends}, ${misc:Depends}, tirex, libwww-perl Description: WMS backend for the Tirex tile rendering system The Tirex suite of programs manages map tile rendering and caching. This is the WMS backend for fetching maps from a WMS server. Package: tirex-backend-mapserver Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, tirex-core, libwww-perl, libmapscript-perl, ttf-dejavu-core +Depends: ${shlibs:Depends}, ${misc:Depends}, tirex, libwww-perl, libmapscript-perl, ttf-dejavu-core Description: Mapserver backend for the Tirex tile rendering system The Tirex suite of programs manages map tile rendering and caching. This is the Mapserver backend for rendering maps with Mapserver. Package: tirex-backend-mapnik Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, tirex-core +Depends: ${shlibs:Depends}, ${misc:Depends}, tirex Description: Mapnik backend for the Tirex tile rendering system The Tirex suite of programs manages map tile rendering and caching. This is the Mapnik backend for creating maps with the Mapnik renderer. Package: tirex-backend-openseamap Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, tirex-core, default-jre-headless | java8-runtime-headless +Depends: ${shlibs:Depends}, ${misc:Depends}, tirex, default-jre-headless | java8-runtime-headless Description: OpenSeaMap backend for the Tirex tile rendering system The Tirex suite of programs manages map tile rendering and caching. This is the OpenSeaMap backend for creating maps with the OpenSeaMap renderer. -Package: tirex-backend-tms -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, tirex-core, libwww-perl, libnet-https-nb-perl, libhttp-async-perl -Description: WMS backend for the Tirex tile rendering system - The Tirex suite of programs manages map tile rendering and caching. - This is the WMS backend for fetching maps from a WMS server. - Package: tirex-syncd Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, tirex-core +Depends: ${shlibs:Depends}, ${misc:Depends}, tirex Description: Tirex sync daemon The Tirex suite of programs manages map tile rendering and caching. This is the sync daemon which listens for messages of tiles fully rendered, and then copies the metatile to another server. The sync daemon is intended to be used in setups where you have multiple tile servers with their own rendering queues. - -Package: tirex-example-map -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, tirex-backend-mapnik -Description: Tirex example map data - The Tirex suite of programs manages map tile rendering and caching. - This package includes example map data and an example config for the Mapnik - renderer. diff --git a/debian/copyright b/debian/copyright index 9b88bc6..c4698da 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,24 +1,43 @@ -Tirex Rendering System +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: Tirex +Upstream-Contact: Frederik Ramm +Source: https://github.com/openstreetmap/tirex -Copyright (C) 2010 Frederik Ramm and - Jochen Topf +Files: * +Copyright: 2010, 2019-2020, Frederik Ramm + 2010-2011, Jochen Topf + 2012, Sven Geggus +License: GPL-2+ -Initially developed by Geofabrik GmbH, Karlsruhe, Germany, with -support from Enaikoon GmbH, Berlin, Germany. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. +Files: example-map/ocean.gpkg +Copyright: 2009-2016, Natural Earth +License: public-domain + This data is explicitly placed in the public domain. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +Files: utils/analyze_postgis_log.pl +Copyright: 2010-2016, Frederik Ramm +License: public-domain + This file is explicitly placed in the public domain. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +Files: debian/* +Copyright: 2010-2020, Frederik Ramm + 2020-2021, Felix Delattre +License: GPL-2+ -On Debian systems, the license text can usually be found in -/usr/share/common-licenses. +License: GPL-2+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + . + On Debian systems, the complete text of the GNU General Public License + version 2 or later can be found in `/usr/share/common-licenses/GPL-2'. diff --git a/debian/etc/apache2/tirex-example-map.conf b/debian/etc/apache2/tirex-example-map.conf new file mode 100644 index 0000000..064ebb9 --- /dev/null +++ b/debian/etc/apache2/tirex-example-map.conf @@ -0,0 +1,149 @@ +Alias /tirex-example-map /usr/share/tirex/example-map + + + Options +FollowSymLinks + AllowOverride All + order allow,deny + allow from all + + +Listen 8083 + + + ModTileTileDir /var/cache/tirex/tiles + + # You can manually configure each tile set with AddTileConfig or AddTileMimeConfig. + # The first argument is the URL path relative to this virtual host + # under which a tile set is served. The second argument specifies the + # name of the tile set. This is used in the communication with tirex + # and is the directory under which (meta)tiles are stored on disk. + # + # By default (AddTileConfig) mod_tile assumes you are serving png files, however, + # mod_tile can also serve arbitrary other tile types such as javascript vector tiles, + # assuming the backend render daemon can handle the file type. + # To this purpose AddTileMimeConfig takes a 3rd agument, the file extension and it + # will guess the correct mimetype from it. If the mime type is not set correctly automatically, + # you need to use the configuration file route, where you can specify the mimetype and file extension + # independently. + # + #AddTileConfig /folder/ TileSetName + AddTileConfig /tiles/tirex-example tirex-example + + #AddTileMimeConfig /folder2/ TileSetName2 js + + # Alternatively (or in addition) you can load all the tile sets defined in the configuration file into this virtual host + #LoadTileConfigFile /route-to-file + + # Specify if mod_tile should keep tile delivery stats, which can be accessed from the URL /mod_tile + # The default is On. As keeping stats needs to take a lock, this might have some performance impact, + # but for nearly all intents and purposes this should be negligable and so it is safe to keep this turned on. + ModTileEnableStats On + + # Turns on bulk mode. In bulk mode, mod_tile does not request any dirty tiles to be rerendered. Missing tiles + # are always requested in the lowest priority. The default is Off. + ModTileBulkMode Off + + # Timeout before giving up for a tile to be rendered + ModTileRequestTimeout 0 + + # Timeout before giving up for a tile to be rendered that is otherwise missing + ModTileMissingRequestTimeout 60 + + # If tile is out of date, don't re-render it if past this load threshold (users gets old tile) + ModTileMaxLoadOld 2 + + # If tile is missing, don't render it if past this load threshold (user gets 404 error) + ModTileMaxLoadMissing 5 + + # Socket where we connect to the rendering daemon + ModTileRenderdSocketName /run/tirex/modtile.sock + + # Options controlling the cache proxy expiry headers. All values are in seconds. + # + # Caching is both important to reduce the load and bandwidth of the server, as + # well as reduce the load time for the user. The site loads fastest if tiles can be + # taken from the users browser cache and no round trip through the internet is needed. + # With minutely or hourly updates, however there is a trade-off between cacheability + # and freshness. As one can't predict the future, these are only heuristics, that + # need tuning. + # If there is a known update schedule such as only using weekly planet dumps to update the db, + # this can also be taken into account through the constant PLANET_INTERVAL in render_config.h + # but requires a recompile of mod_tile + + # The values in this sample configuration are not the same as the defaults + # that apply if the config settings are left out. The defaults are more conservative + # and disable most of the heuristics. + + # Caching is always a trade-off between being up to date and reducing server load or + # client side latency and bandwidth requirements. Under some conditions, like poor + # network conditions it might be more important to have good caching rather than the latest tiles. + # Therefor the following config options allow to set a special hostheader for which the caching + # behaviour is different to the normal heuristics + # + # The CacheExtended parameters overwrite all other caching parameters (including CacheDurationMax) + # for tiles being requested via the hostname CacheExtendedHostname + # + #ModTileCacheExtendedHostname cache.tile.openstreetmap.org + #ModTileCacheExtendedDuration 2592000 + + # Upper bound on the length a tile will be set cacheable, which takes + # precedence over other settings of cacheing + ModTileCacheDurationMax 604800 + + # Sets the time tiles can be cached for that are known to by outdated and have been + # sent to tirex to be rerendered. This should be set to a value corresponding + # roughly to how long it will take tirex to get through its queue. There is an additional + # fuzz factor on top of this to not have all tiles expire at the same time + ModTileCacheDurationDirty 900 + + # Specify the minimum time mod_tile will set the cache expiry to for fresh tiles. There + # is an additional fuzz factor of between 0 and 3 hours on top of this. + ModTileCacheDurationMinimum 10800 + + # Lower zoom levels are less likely to change noticeable, so these could be cached for longer + # without users noticing much. + # The heuristic offers three levels of zoom, Low, Medium and High, for which different minimum + # cacheing times can be specified. + + #Specify the zoom level below which Medium starts and the time in seconds for which they can be cached + ModTileCacheDurationMediumZoom 13 86400 + + #Specify the zoom level below which Low starts and the time in seconds for which they can be cached + ModTileCacheDurationLowZoom 9 518400 + + # A further heuristic to determine cacheing times is when was the last time a tile has changed. + # If it hasn't changed for a while, it is less likely to change in the immediate future, so the + # tiles can be cached for longer. + # For example, if the factor is 0.20 and the tile hasn't changed in the last 5 days, it can be cached + # for up to one day without having to re-validate. + ModTileCacheLastModifiedFactor 0.20 + + # Tile Throttling + # Tile scrapers can often download large numbers of tiles and overly strain tileserver resources + # mod_tile therefore offers the ability to automatically throttle requests from ip addresses that have + # requested a lot of tiles. + # The mechanism uses a token bucket approach to shape traffic. I.e. there is an initial pool of n tiles + # per ip that can be requested arbitrarily fast. After that this pool gets filled up at a constant rate + # The algorithm has two metrics. One based on overall tiles served to an ip address and a second one based on + # the number of requests to tirex / tirex to render a new tile. + + # Overall enable or disable tile throttling + ModTileEnableTileThrottling Off + + # Specify if you want to use the connecting IP for throtteling, or use the X-Forwarded-For header to determin the + # 1 - use the client IP address, i.e. the first entry in the X-Forwarded-For list. This works through a cascade of proxies. + # However, as the X-Forwarded-For is written by the client this is open to manipulation and can be used to circumvent the throttling + # 2 - use the last specified IP in the X-Forwarded-For list. If you know all requests come through a reverse proxy + # that adds an X-Forwarded-For header, you can trust this IP to be the IP the reverse proxy saw for the request + ModTileEnableTileThrottlingXForward 0 + + # Parameters (poolsize in tiles and topup rate in tiles per second) for throttling tile serving. + ModTileThrottlingTiles 10000 1 + # Parameters (poolsize in tiles and topup rate in tiles per second) for throttling render requests. + ModTileThrottlingRenders 128 0.2 + + # Block internal commands + RedirectMatch 404 /tiles/.*/dirty + RedirectMatch 404 /tiles/.*/status + + diff --git a/debian/etc/apache2/tirex.conf b/debian/etc/apache2/tirex.conf new file mode 100644 index 0000000..d6b3d21 --- /dev/null +++ b/debian/etc/apache2/tirex.conf @@ -0,0 +1,140 @@ +Listen 8082 + + + ModTileTileDir /var/cache/tirex/tiles + + # You can manually configure each tile set with AddTileConfig or AddTileMimeConfig. + # The first argument is the URL path relative to this virtual host + # under which a tile set is served. The second argument specifies the + # name of the tile set. This is used in the communication with tirex + # and is the directory under which (meta)tiles are stored on disk. + # + # By default (AddTileConfig) mod_tile assumes you are serving png files, however, + # mod_tile can also serve arbitrary other tile types such as javascript vector tiles, + # assuming the backend render daemon can handle the file type. + # To this purpose AddTileMimeConfig takes a 3rd agument, the file extension and it + # will guess the correct mimetype from it. If the mime type is not set correctly automatically, + # you need to use the configuration file route, where you can specify the mimetype and file extension + # independently. + # + #AddTileConfig /folder/ TileSetName + AddTileConfig /tiles/test test + + #AddTileMimeConfig /folder2/ TileSetName2 js + + # Alternatively (or in addition) you can load all the tile sets defined in the configuration file into this virtual host + #LoadTileConfigFile /route-to-file + + # Specify if mod_tile should keep tile delivery stats, which can be accessed from the URL /mod_tile + # The default is On. As keeping stats needs to take a lock, this might have some performance impact, + # but for nearly all intents and purposes this should be negligable and so it is safe to keep this turned on. + ModTileEnableStats On + + # Turns on bulk mode. In bulk mode, mod_tile does not request any dirty tiles to be rerendered. Missing tiles + # are always requested in the lowest priority. The default is Off. + ModTileBulkMode Off + + # Timeout before giving up for a tile to be rendered + ModTileRequestTimeout 0 + + # Timeout before giving up for a tile to be rendered that is otherwise missing + ModTileMissingRequestTimeout 60 + + # If tile is out of date, don't re-render it if past this load threshold (users gets old tile) + ModTileMaxLoadOld 2 + + # If tile is missing, don't render it if past this load threshold (user gets 404 error) + ModTileMaxLoadMissing 5 + + # Socket where we connect to the rendering daemon + ModTileRenderdSocketName /run/tirex/modtile.sock + + # Options controlling the cache proxy expiry headers. All values are in seconds. + # + # Caching is both important to reduce the load and bandwidth of the server, as + # well as reduce the load time for the user. The site loads fastest if tiles can be + # taken from the users browser cache and no round trip through the internet is needed. + # With minutely or hourly updates, however there is a trade-off between cacheability + # and freshness. As one can't predict the future, these are only heuristics, that + # need tuning. + # If there is a known update schedule such as only using weekly planet dumps to update the db, + # this can also be taken into account through the constant PLANET_INTERVAL in render_config.h + # but requires a recompile of mod_tile + + # The values in this sample configuration are not the same as the defaults + # that apply if the config settings are left out. The defaults are more conservative + # and disable most of the heuristics. + + # Caching is always a trade-off between being up to date and reducing server load or + # client side latency and bandwidth requirements. Under some conditions, like poor + # network conditions it might be more important to have good caching rather than the latest tiles. + # Therefor the following config options allow to set a special hostheader for which the caching + # behaviour is different to the normal heuristics + # + # The CacheExtended parameters overwrite all other caching parameters (including CacheDurationMax) + # for tiles being requested via the hostname CacheExtendedHostname + # + #ModTileCacheExtendedHostname cache.tile.openstreetmap.org + #ModTileCacheExtendedDuration 2592000 + + # Upper bound on the length a tile will be set cacheable, which takes + # precedence over other settings of cacheing + ModTileCacheDurationMax 604800 + + # Sets the time tiles can be cached for that are known to by outdated and have been + # sent to tirex to be rerendered. This should be set to a value corresponding + # roughly to how long it will take tirex to get through its queue. There is an additional + # fuzz factor on top of this to not have all tiles expire at the same time + ModTileCacheDurationDirty 900 + + # Specify the minimum time mod_tile will set the cache expiry to for fresh tiles. There + # is an additional fuzz factor of between 0 and 3 hours on top of this. + ModTileCacheDurationMinimum 10800 + + # Lower zoom levels are less likely to change noticeable, so these could be cached for longer + # without users noticing much. + # The heuristic offers three levels of zoom, Low, Medium and High, for which different minimum + # cacheing times can be specified. + + #Specify the zoom level below which Medium starts and the time in seconds for which they can be cached + ModTileCacheDurationMediumZoom 13 86400 + + #Specify the zoom level below which Low starts and the time in seconds for which they can be cached + ModTileCacheDurationLowZoom 9 518400 + + # A further heuristic to determine cacheing times is when was the last time a tile has changed. + # If it hasn't changed for a while, it is less likely to change in the immediate future, so the + # tiles can be cached for longer. + # For example, if the factor is 0.20 and the tile hasn't changed in the last 5 days, it can be cached + # for up to one day without having to re-validate. + ModTileCacheLastModifiedFactor 0.20 + + # Tile Throttling + # Tile scrapers can often download large numbers of tiles and overly strain tileserver resources + # mod_tile therefore offers the ability to automatically throttle requests from ip addresses that have + # requested a lot of tiles. + # The mechanism uses a token bucket approach to shape traffic. I.e. there is an initial pool of n tiles + # per ip that can be requested arbitrarily fast. After that this pool gets filled up at a constant rate + # The algorithm has two metrics. One based on overall tiles served to an ip address and a second one based on + # the number of requests to tirex / tirex to render a new tile. + + # Overall enable or disable tile throttling + ModTileEnableTileThrottling Off + + # Specify if you want to use the connecting IP for throtteling, or use the X-Forwarded-For header to determin the + # 1 - use the client IP address, i.e. the first entry in the X-Forwarded-For list. This works through a cascade of proxies. + # However, as the X-Forwarded-For is written by the client this is open to manipulation and can be used to circumvent the throttling + # 2 - use the last specified IP in the X-Forwarded-For list. If you know all requests come through a reverse proxy + # that adds an X-Forwarded-For header, you can trust this IP to be the IP the reverse proxy saw for the request + ModTileEnableTileThrottlingXForward 0 + + # Parameters (poolsize in tiles and topup rate in tiles per second) for throttling tile serving. + ModTileThrottlingTiles 10000 1 + # Parameters (poolsize in tiles and topup rate in tiles per second) for throttling render requests. + ModTileThrottlingRenders 128 0.2 + + # Block internal commands + RedirectMatch 404 /tiles/.*/dirty + RedirectMatch 404 /tiles/.*/status + + diff --git a/debian/etc/logrotate.d/tirex b/debian/etc/logrotate.d/tirex new file mode 100644 index 0000000..a994402 --- /dev/null +++ b/debian/etc/logrotate.d/tirex @@ -0,0 +1,10 @@ +# /etc/logrotate.d/tirex +/var/log/tirex/jobs.log { + daily + rotate 35 + dateext + compress + missingok + notifempty + create 0644 _tirex _tirex +} diff --git a/debian/etc/tirex/renderer/mapnik.conf b/debian/etc/tirex/renderer/mapnik.conf new file mode 100644 index 0000000..9ffca33 --- /dev/null +++ b/debian/etc/tirex/renderer/mapnik.conf @@ -0,0 +1,49 @@ +#----------------------------------------------------------------------------- +# +# Konfiguration for Mapnik renderer +# +# /etc/tirex/renderer/mapnik.conf +# +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# General configuration +#----------------------------------------------------------------------------- + +# symbolic name +name=mapnik + +# path to executable of renderer +path=/usr/libexec/tirex-backend-mapnik + +# UDP port where the master can contact this renderer +# must be individual for each renderer +port=9331 + +# number of processes that should be started +procs=3 + +# syslog facility +#syslog_facility=daemon + +# activate this to see debug messages from renderer +#debug=1 + +#----------------------------------------------------------------------------- +# Backend specific configuration +#----------------------------------------------------------------------------- + +# Directory with input plugins for mapnik. The directory of your mapnik +# installation can be retrieved by this command: mapnik-config --input-plugins +plugindir=/usr/share/tirex/mapnik/input + +# The directory where the Mapnik rendering engine loads its TrueType fonts from. +# If the style sheet references fonts that are not present here, the renderer will +# throw an exception. +fontdir=/usr/share/fonts/truetype + +# Set this to 1 if you want fonts loaded recursively from directories +# inside the mapnik_fontdir directory. Defaults to 0. +fontdir_recurse=1 + +#-- THE END ------------------------------------------------------------------ diff --git a/debian/etc/tirex/renderer/mapnik/tirex-example.conf b/debian/etc/tirex/renderer/mapnik/tirex-example.conf new file mode 100644 index 0000000..3e257c1 --- /dev/null +++ b/debian/etc/tirex/renderer/mapnik/tirex-example.conf @@ -0,0 +1,31 @@ +#----------------------------------------------------------------------------- +# +# Konfiguration for tirex example map. +# +# /etc/tirex/renderer/mapnik/tirex-example.conf +# +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# General configuration +#----------------------------------------------------------------------------- + +# symbolic name of this map +name=tirex-example + +# tile directory +tiledir=/var/cache/tirex/tiles/tirex-example + +# minimum zoom level allowed +#minz=0 + +# maximum zoom level allowed +maxz=12 + +#----------------------------------------------------------------------------- +# Backend specific configuration +#----------------------------------------------------------------------------- + +mapfile=/usr/share/tirex/example-map/example.xml + +#-- THE END ------------------------------------------------------------------ diff --git a/debian/etc/tirex/renderer/test.conf b/debian/etc/tirex/renderer/test.conf new file mode 100644 index 0000000..9374690 --- /dev/null +++ b/debian/etc/tirex/renderer/test.conf @@ -0,0 +1,38 @@ +#----------------------------------------------------------------------------- +# +# Konfiguration for Test renderer +# +# /etc/tirex/renderer/test.conf +# +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# General configuration +#----------------------------------------------------------------------------- + +# symbolic name +name=test + +# path to executable of renderer +path=/usr/libexec/tirex-backend-test + +# UDP port where the master can contact this renderer +# must be individual for each renderer +port=9330 + +# number of processes that should be started +procs=2 + +# syslog facility +#syslog_facility=daemon + +# activate this to see debug messages from renderer +#debug=1 + +#----------------------------------------------------------------------------- +# Backend specific configuration +#----------------------------------------------------------------------------- + +# none + +#-- THE END ------------------------------------------------------------------ diff --git a/debian/etc/tirex/renderer/test/checkerboard.conf b/debian/etc/tirex/renderer/test/checkerboard.conf new file mode 100644 index 0000000..3374ce8 --- /dev/null +++ b/debian/etc/tirex/renderer/test/checkerboard.conf @@ -0,0 +1,33 @@ +#----------------------------------------------------------------------------- +# +# Konfiguration for test map +# +# /etc/tirex/renderer/test/checkerboard.conf +# +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# General configuration +#----------------------------------------------------------------------------- + +# symbolic name of this map +name=test + +# tile directory +tiledir=/var/cache/tirex/tiles/test + +# minimum zoom level allowed (default 0) +#minz=0 + +# maximum zoom level allowed (default 17) +maxz=10 + +#----------------------------------------------------------------------------- +# Backend specific configuration +#----------------------------------------------------------------------------- + +# time the renderer should sleep to simulate rendering time (default is 0) +#sleep=0 + + +#-- THE END ------------------------------------------------------------------ diff --git a/debian/etc/tirex/tirex.conf b/debian/etc/tirex/tirex.conf new file mode 100644 index 0000000..f8e5544 --- /dev/null +++ b/debian/etc/tirex/tirex.conf @@ -0,0 +1,60 @@ +#----------------------------------------------------------------------------- +# +# /etc/tirex/tirex.conf +# +# Configuration file for the Tirex tile rendering system. +# +#----------------------------------------------------------------------------- + +# Directory where statistics are stored +stats_dir=/var/cache/tirex/stats + +# How many rows and columns of tiles are there in a metatile. +#metatile_rows=8 +#metatile_columns=8 + +# The name of the UNIX domain socket for communicating with ModTile. +modtile_socket_name=/run/tirex/modtile.sock + +# Directory where UNIX domain sockets are created +socket_dir=/run/tirex + +#----------------------------------------------------------------------------- +# MASTER +#----------------------------------------------------------------------------- + +# The master writes its process ID into this file. +master_pidfile=/run/tirex/tirex-master.pid + +# Syslog facility used in tirex-master. +#master_syslog_facility=daemon + +# Logfile where all rendered jobs are logged. +#master_logfile=/var/log/tirex/jobs.log + +# If the rendering of a metatile takes more than this many minutes the master +# gives up on it and removes the job from the list of currently rendering tiles. +# This must be larger than backend_manager_alive_timeout and should be larger than +# the rendering of any tile can need. Its only used to make sure that a +# rendering process that is long gone doesn't take up resources forever. +#master_rendering_timeout=10 + +# Buckets for different priorities. +bucket name=live minprio=1 maxproc=4 maxload=20 +bucket name=important minprio=10 maxproc=3 maxload=8 +bucket name=background minprio=20 maxproc=2 maxload=4 + +#----------------------------------------------------------------------------- +# BACKEND-MANAGER +#----------------------------------------------------------------------------- + +# The tirex-backend-manager writes its process ID into this file +backend_manager_pidfile=/run/tirex/tirex-backend-manager.pid + +# Syslog facility used by tirex-backend-manager +#backend_manager_syslog_facility=daemon + +# If a rendering process doesn't send an alive message in this many minutes +# to the backend-manager, it will be killed by the manager. Make this smaller +# than master_rendering_timeout. +#backend_manager_alive_timeout=8 diff --git a/debian/gbp.conf b/debian/gbp.conf new file mode 100644 index 0000000..e3daba6 --- /dev/null +++ b/debian/gbp.conf @@ -0,0 +1,19 @@ +[DEFAULT] + +# The default name for the upstream branch is "upstream". +# Change it if the name is different (for instance, "master"). +upstream-branch = upstream + +# The default name for the Debian branch is "master". +# Change it if the name is different (for instance, "debian/unstable"). +debian-branch = master + +# git-import-orig uses the following names for the upstream tags. +# Change the value if you are not using git-import-orig +upstream-tag = upstream/%(version)s + +# Always use pristine-tar. +pristine-tar = True + +[buildpackage] +pbuilder-options = --source-only-changes diff --git a/debian/not-installed b/debian/not-installed new file mode 100644 index 0000000..4b79792 --- /dev/null +++ b/debian/not-installed @@ -0,0 +1,20 @@ +etc/tirex/renderer/mapnik.conf +etc/tirex/renderer/mapserver.conf +etc/tirex/renderer/mapserver/fonts.lst +etc/tirex/renderer/mapserver/msdemo.conf +etc/tirex/renderer/mapserver/msdemo.map +etc/tirex/renderer/openseamap.conf +etc/tirex/renderer/openseamap/openseamap.conf +etc/tirex/renderer/test.conf +etc/tirex/renderer/test/checkerboard.conf +etc/tirex/renderer/tms.conf +etc/tirex/renderer/tms/demotms.conf +etc/tirex/renderer/wms.conf +etc/tirex/renderer/wms/demowms.conf +etc/tirex/tirex.conf +usr/bin/tirex-syncd +usr/libexec/tirex-backend-mapserver +usr/libexec/tirex-backend-openseamap +usr/libexec/tirex-backend-tms +usr/libexec/tirex-backend-wms +usr/share/man/man1/tirex-syncd.1 diff --git a/debian/rules b/debian/rules index 328f598..48a063e 100755 --- a/debian/rules +++ b/debian/rules @@ -1,78 +1,15 @@ #!/usr/bin/make -f -configure: configure-stamp -configure-stamp: - dh_testdir - - # commands to configure the package. - touch configure-stamp +# Uncomment this to turn on verbose mode. +#DH_VERBOSE=1 -build: build-stamp +# Enable hardening build flags +export DEB_BUILD_MAINT_OPTIONS=hardening=+all -build-stamp: configure-stamp - dh_testdir +%: + dh $@ --with apache2 - # commands to compile the package. - $(MAKE) - touch $@ +override_dh_auto_install: + dh_auto_install --destdir=debian/tmp -- install-all -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - - # commands to clean up after the build process. - $(MAKE) clean - dh_clean - -install: build - dh_testdir - dh_testroot - dh_prep - dh_installdirs - - # commands to install the package into debian/tmp - $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install-all - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installchangelogs - dh_installdocs - dh_installexamples -# the following line handles all packages *except* tirex-core - dh_install --no-package tirex-core --sourcedir=$(CURDIR)/debian/tmp -# the following line handles *only* the tirex-core package, it excludes some perl libraries that should not end up in this package - dh_install --no-package tirex-backend-wms --no-package tirex-backend-mapserver --no-package tirex-backend-openseamap --no-package tirex-backend-mapnik --no-package tirex-munin-plugin --no-package tirex-nagios-plugin --no-package tirex-syncd --no-package tirex-example-map --exclude Munin --exclude Tirex::Backend::WMS --exclude Tirex::Backend::Mapserver --exclude Tirex::Backend::OpenSeaMap --exclude Tirex::Backend::TMS --exclude Backend/WMS --exclude Backend/Mapserver --exclude Backend/OpenSeaMap --exclude Backend/TMS --sourcedir=$(CURDIR)/debian/tmp -# dh_installmenu -# dh_installdebconf -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_python - dh_installinit --name=tirex-master - dh_installinit --name=tirex-backend-manager - dh_installinit -# dh_installcron -# dh_installinfo - dh_installman - dh_link - dh_strip - dh_compress - dh_fixperms -# dh_perl -# dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure +.PHONY: templates diff --git a/debian/share/index.html b/debian/share/index.html new file mode 100644 index 0000000..e169a99 --- /dev/null +++ b/debian/share/index.html @@ -0,0 +1,23 @@ + + + + tirex example map + + + + + + + + +
+ + + + + diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/tirex-backend-manager.service b/debian/tirex-backend-manager.service index 92d19d9..728ba00 100644 --- a/debian/tirex-backend-manager.service +++ b/debian/tirex-backend-manager.service @@ -1,16 +1,16 @@ [Unit] Description=Backend of tirex rendering system +Documentation=man:tirex-backend-manager After=network.target auditd.service -Before=apache2.service tirex-master.service +PartOf=tirex-master.service [Service] ExecStart=/usr/bin/tirex-backend-manager -f ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure -User=tirex -Group=tirex -RuntimeDirectory=tirex +User=_tirex +Group=_tirex [Install] WantedBy=multi-user.target diff --git a/debian/tirex-backend-mapnik.install b/debian/tirex-backend-mapnik.install deleted file mode 100644 index f1ee803..0000000 --- a/debian/tirex-backend-mapnik.install +++ /dev/null @@ -1,2 +0,0 @@ -usr/libexec/tirex-backend-mapnik -etc/tirex/renderer/mapnik.conf diff --git a/debian/tirex-backend-mapnik.postinst b/debian/tirex-backend-mapnik.postinst deleted file mode 100644 index 475097b..0000000 --- a/debian/tirex-backend-mapnik.postinst +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/sh - -set -e - -[ -d /etc/tirex/renderer/mapnik ] || mkdir -p /etc/tirex/renderer/mapnik - -#DEBHELPER# diff --git a/debian/tirex-backend-mapserver.install b/debian/tirex-backend-mapserver.install index 326ca2c..293c3e0 100644 --- a/debian/tirex-backend-mapserver.install +++ b/debian/tirex-backend-mapserver.install @@ -1,6 +1,4 @@ usr/libexec/tirex-backend-mapserver -usr/share/perl5/Tirex/Backend/Mapserver.pm -usr/share/man/man3/Tirex::Backend::Mapserver.3pm etc/tirex/renderer/mapserver.conf etc/tirex/renderer/mapserver/msdemo.conf etc/tirex/renderer/mapserver/msdemo.map diff --git a/debian/tirex-backend-tms.install b/debian/tirex-backend-tms.install index 23b4586..32e6c00 100644 --- a/debian/tirex-backend-tms.install +++ b/debian/tirex-backend-tms.install @@ -1,5 +1,3 @@ usr/libexec/tirex-backend-tms -usr/share/perl5/Tirex/Backend/TMS.pm -usr/share/man/man3/Tirex::Backend::TMS.3pm etc/tirex/renderer/tms.conf etc/tirex/renderer/tms/demotms.conf diff --git a/debian/tirex-backend-wms.install b/debian/tirex-backend-wms.install index bd183f7..5a15466 100644 --- a/debian/tirex-backend-wms.install +++ b/debian/tirex-backend-wms.install @@ -1,5 +1,3 @@ usr/libexec/tirex-backend-wms -usr/share/perl5/Tirex/Backend/WMS.pm -usr/share/man/man3/Tirex::Backend::WMS.3pm etc/tirex/renderer/wms.conf etc/tirex/renderer/wms/demowms.conf diff --git a/debian/tirex-core.postinst b/debian/tirex-core.postinst index 4c3fffc..6c273f4 100644 --- a/debian/tirex-core.postinst +++ b/debian/tirex-core.postinst @@ -6,7 +6,7 @@ if ! getent passwd tirex >/dev/null; then adduser --group --system --no-create-home --shell /bin/bash --home /var/lib/tirex tirex fi -for dir in /var/run/tirex /var/log/tirex /var/lib/tirex /var/cache/tirex/stats /var/lib/tirex/tiles /var/lib/tirex/tiles/test; do +for dir in /run/tirex /var/log/tirex /var/lib/tirex /var/cache/tirex/stats /var/cache/tirex/tiles /var/cache/tirex/tiles/test; do [ -d $dir ] || mkdir -p $dir && chown tirex:tirex $dir done diff --git a/debian/tirex-example-map.apache2 b/debian/tirex-example-map.apache2 new file mode 100644 index 0000000..909426f --- /dev/null +++ b/debian/tirex-example-map.apache2 @@ -0,0 +1 @@ +conf debian/etc/apache2/tirex-example-map.conf diff --git a/debian/tirex-example-map.dirs b/debian/tirex-example-map.dirs new file mode 100644 index 0000000..d9f1d7b --- /dev/null +++ b/debian/tirex-example-map.dirs @@ -0,0 +1 @@ +var/cache/tirex/tiles/tirex-example diff --git a/debian/tirex-example-map.install b/debian/tirex-example-map.install index c458053..885036b 100644 --- a/debian/tirex-example-map.install +++ b/debian/tirex-example-map.install @@ -1,2 +1,4 @@ -etc/tirex/renderer/mapnik/example.conf -usr/share/tirex/example-map +debian/etc/tirex/renderer/mapnik/tirex-example.conf etc/tirex/renderer/mapnik +debian/share/index.html usr/share/tirex/example-map +example-map/example.xml usr/share/tirex/example-map +example-map/ocean.gpkg usr/share/tirex/example-map diff --git a/debian/tirex-example-map.links b/debian/tirex-example-map.links new file mode 100644 index 0000000..44be68f --- /dev/null +++ b/debian/tirex-example-map.links @@ -0,0 +1 @@ +usr/share/javascript/leaflet usr/share/tirex/example-map/leaflet diff --git a/debian/tirex-example-map.lintian-overrides b/debian/tirex-example-map.lintian-overrides new file mode 100644 index 0000000..e8f208c --- /dev/null +++ b/debian/tirex-example-map.lintian-overrides @@ -0,0 +1,2 @@ +# A file to serve the example map is not documentation +package-contains-documentation-outside-usr-share-doc diff --git a/debian/tirex-example-map.postinst b/debian/tirex-example-map.postinst index 0ffdb03..384d832 100644 --- a/debian/tirex-example-map.postinst +++ b/debian/tirex-example-map.postinst @@ -1,7 +1,10 @@ -#! /bin/sh +#!/bin/sh set -e -[ -d /var/cache/tirex/tiles/example ] || mkdir -p /var/cache/tirex/tiles/example && chown tirex:tirex /var/cache/tirex/tiles/example +echo "Check out the tirex example map by visiting:" +echo " http://localhost/tirex-example-map" + +chown _tirex:_tirex /var/cache/tirex/tiles/tirex-example #DEBHELPER# diff --git a/debian/tirex-master.service b/debian/tirex-master.service index f8a6c2d..a06053a 100644 --- a/debian/tirex-master.service +++ b/debian/tirex-master.service @@ -1,5 +1,6 @@ [Unit] Description=Master process of tirex rendering system +Documentation=man:tirex-master After=network.target auditd.service Before=apache2.service @@ -8,9 +9,8 @@ ExecStart=/usr/bin/tirex-master -f ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure -User=tirex -Group=tirex -RuntimeDirectory=tirex +User=_tirex +Group=_tirex [Install] WantedBy=multi-user.target diff --git a/debian/tirex-munin-plugin.install b/debian/tirex-munin-plugin.install index f6b6367..ce7cff7 100644 --- a/debian/tirex-munin-plugin.install +++ b/debian/tirex-munin-plugin.install @@ -1,4 +1 @@ -usr/share/man/man3/Tirex::Munin* -usr/share/perl5/Tirex/Munin -usr/share/perl5/Tirex/Munin.pm usr/share/munin/plugins/* diff --git a/debian/tirex.apache2 b/debian/tirex.apache2 new file mode 100644 index 0000000..570cc3d --- /dev/null +++ b/debian/tirex.apache2 @@ -0,0 +1 @@ +conf debian/etc/apache2/tirex.conf diff --git a/debian/tirex.dirs b/debian/tirex.dirs new file mode 100644 index 0000000..0cea538 --- /dev/null +++ b/debian/tirex.dirs @@ -0,0 +1,4 @@ +var/cache/tirex/tiles +var/cache/tirex/tiles/test +var/cache/tirex/stats +var/log/tirex diff --git a/debian/tirex.examples b/debian/tirex.examples new file mode 100644 index 0000000..0e6a6d0 --- /dev/null +++ b/debian/tirex.examples @@ -0,0 +1,2 @@ +utils/* +example-map/mapnik-example.conf diff --git a/debian/tirex.install b/debian/tirex.install new file mode 100644 index 0000000..42ae3bf --- /dev/null +++ b/debian/tirex.install @@ -0,0 +1,30 @@ +usr/bin/tirex-backend-manager +usr/bin/tirex-batch +usr/bin/tirex-check-config +usr/bin/tirex-master +usr/bin/tirex-rendering-control +usr/bin/tirex-send +usr/bin/tirex-status +usr/bin/tirex-tiledir-check +usr/bin/tirex-tiledir-stat +usr/share/man/man1/tirex-backend-manager.1 +usr/share/man/man1/tirex-batch.1 +usr/share/man/man1/tirex-check-config.1 +usr/share/man/man1/tirex-master.1 +usr/share/man/man1/tirex-rendering-control.1 +usr/share/man/man1/tirex-send.1 +usr/share/man/man1/tirex-status.1 +usr/share/man/man1/tirex-tiledir-check.1 +usr/share/man/man1/tirex-tiledir-stat.1 +usr/share/man/man3 +usr/share/perl5 +debian/etc/logrotate.d/tirex etc/logrotate.d +debian/etc/tirex/renderer/test.conf etc/tirex/renderer +debian/etc/tirex/renderer/test/checkerboard.conf etc/tirex/renderer/test +debian/etc/tirex/tirex.conf etc/tirex +debian/etc/tirex/renderer/mapnik.conf etc/tirex/renderer +debian/tmpfiles.d/tirex.conf usr/lib/tmpfiles.d +debian/tirex-master.service usr/lib/systemd/system/ +debian/tirex-backend-manager.service usr/lib/systemd/system/ +usr/libexec/tirex-backend-mapnik +usr/libexec/tirex-backend-test diff --git a/debian/tirex.links b/debian/tirex.links new file mode 100755 index 0000000..8ac1aac --- /dev/null +++ b/debian/tirex.links @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "$(mapnik-plugin-base) /usr/share/tirex/mapnik/input" diff --git a/debian/tirex.lintian-overrides b/debian/tirex.lintian-overrides new file mode 100644 index 0000000..9d480e5 --- /dev/null +++ b/debian/tirex.lintian-overrides @@ -0,0 +1,2 @@ +# This package only provides systemd unit files: +package-supports-alternative-init-but-no-init.d-script diff --git a/debian/tirex.postinst b/debian/tirex.postinst new file mode 100644 index 0000000..1a733a9 --- /dev/null +++ b/debian/tirex.postinst @@ -0,0 +1,27 @@ +#! /bin/sh + +set -e + +case "$1" in + configure) + if ! getent group _tirex > /dev/null; then + addgroup --force-badname --quiet --system _tirex + fi + + if ! getent passwd _tirex > /dev/null; then + adduser --force-badname --gecos "tirex daemon" \ + --home /nonexistent --ingroup _tirex \ + --no-create-home --quiet --system _tirex + fi + ;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +chown _tirex:_tirex /var/cache/tirex/tiles/test /var/cache/tirex/stats /var/log/tirex + +#DEBHELPER# diff --git a/debian/tirex.postrm b/debian/tirex.postrm new file mode 100644 index 0000000..884d828 --- /dev/null +++ b/debian/tirex.postrm @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +#DEBHELPER# + +if [ "$1" = "purge" ] ; then + deluser --quiet --system _tirex > /dev/null || true + delgroup --quiet --system _tirex > /dev/null || true +fi diff --git a/debian/tirex.prerm b/debian/tirex.prerm new file mode 100644 index 0000000..f26f739 --- /dev/null +++ b/debian/tirex.prerm @@ -0,0 +1,33 @@ +#!/bin/sh +set -e + +if [ "$1" = "remove" ]; then + + # automatically remove cached tiles + if [ -d /var/cache/tirex/tiles ] + then + rm -rf /var/cache/tirex/tiles + fi + + # automatically remove stats + if [ -d /var/cache/tirex/stats ] + then + rm -rf /var/cache/tirex/stats + fi + + # automatically remove tirex log directory + if [ -d /var/log/tirex ] + then + rm -rf /var/log/tirex + fi + + # automatically remove tirex share directory + if [ -d /usr/share/tirex ] + then + rm -rf /usr/share/tirex + fi + +fi + +#DEBHELPER# + diff --git a/debian/tmpfiles.d/tirex.conf b/debian/tmpfiles.d/tirex.conf new file mode 100644 index 0000000..baf383d --- /dev/null +++ b/debian/tmpfiles.d/tirex.conf @@ -0,0 +1 @@ +d /run/tirex 0755 _tirex _tirex - - diff --git a/debian/upstream/metadata b/debian/upstream/metadata new file mode 100644 index 0000000..360ccd2 --- /dev/null +++ b/debian/upstream/metadata @@ -0,0 +1,5 @@ +--- +Bug-Database: https://github.com/openstreetmap/tirex/issues +Bug-Submit: https://github.com/openstreetmap/tirex/issues/new +Repository: https://github.com/openstreetmap/tirex.git +Repository-Browse: https://github.com/openstreetmap/tirex diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..0be6121 --- /dev/null +++ b/debian/watch @@ -0,0 +1,7 @@ +version=4 +opts=\ +dversionmangle=s/\+(debian|dfsg|ds|deb)\d*$//,\ +uversionmangle=s/(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha)\d*)$/$1~$2/;s/RC/rc/;s/\-/\./g,\ +filenamemangle=s/(?:.*?)?(?:rel|v|tirex)?[\-\_]?(\d\S+)\.(tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))/tirex-$1.$2/ \ +https://github.com/openstreetmap/tirex/tags \ +(?:.*?/archive/(?:.*?/)?)?(?:rel|v|tirex)?[\-\_]?(\d\S+)\.(?:tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz))) diff --git a/etc/tirex.conf.dist b/etc/tirex.conf.dist index 7fdb7b8..5376fcc 100644 --- a/etc/tirex.conf.dist +++ b/etc/tirex.conf.dist @@ -82,6 +82,6 @@ bucket name=background minprio=20 maxproc=2 maxload=4 # command to execute for replicating the space-separated list of files # %FILES% to host %HOST%. By default uses a ssh connection with a # persistent control connection that will be re-created on demand. -#syncd_command=tar -C/ -cf - %FILES% | ssh %HOST% -oControlMaster=auto -oControlPersist=1h -oControlPath=/run/tirex/ssh-control-%h-%r-%p -Tq "tar -C/ -xf -" +#syncd_command=rsync --archive --relative --no-implied-dirs --rsh="ssh -oControlMaster=auto -oControlPersist=1h -oControlPath=$SOCKET_DIR/ssh-control-%h-%r-%p -Tq" %FILES% "%HOST%:/ #-- THE END ------------------------------------------------------------------ diff --git a/lib/Tirex.pm b/lib/Tirex.pm index 86b7ffe..d323219 100644 --- a/lib/Tirex.pm +++ b/lib/Tirex.pm @@ -74,7 +74,7 @@ our $BACKEND_MANAGER_ALIVE_TIMEOUT = 8; # minutes - make this a tad smaller th our $SYNCD_PIDFILE = '/run/tirex/tirex-syncd.pid'; our $SYNCD_UDP_PORT = 9323; our $SYNCD_AGGREGATE_DELAY = 5; -our $SYNCD_COMMAND = qq(tar -C/ -cf - %FILES% | ssh %HOST% -oControlMaster=auto -oControlPersist=1h -oControlPath=$SOCKET_DIR/ssh-control-%h-%r-%p -Tq "tar -C/ -xf -"); +our $SYNCD_COMMAND = qq(rsync --archive --relative --no-implied-dirs --rsh="ssh -oControlMaster=auto -oControlPersist=1h -oControlPath=$SOCKET_DIR/ssh-control-%h-%r-%p -Tq" %FILES% "%HOST%:/"); our $MODTILE_SOCK = "/run/tirex/modtile.sock"; our $MODTILE_PERM = 0666; diff --git a/lib/Tirex/Backend.pm b/lib/Tirex/Backend.pm index dca594f..ffcb59b 100644 --- a/lib/Tirex/Backend.pm +++ b/lib/Tirex/Backend.pm @@ -199,14 +199,22 @@ sub main my $t0 = [Time::HiRes::gettimeofday]; my $image = $self->create_metatile($map, $metatile); - $self->set_status('writing metatile'); + if ($image) + { + $self->set_status('writing metatile'); - $self->write_metatile($image, $filename, $metatile); + $self->write_metatile($image, $filename, $metatile); - $msg = $msg->reply(); - $msg->{'render_time'} = int(Time::HiRes::tv_interval($t0) * 1000); # in milliseconds + $msg = $msg->reply(); + $msg->{'render_time'} = int(Time::HiRes::tv_interval($t0) * 1000); # in milliseconds - ::syslog('debug', 'sending response: %s', $msg->to_s()) if ($Tirex::DEBUG); + ::syslog('debug', 'sending response: %s', $msg->to_s()) if ($Tirex::DEBUG); + } + else + { + ::syslog('err', 'backend error'); + $msg = $msg->reply('ERROR_BACKEND', 'The backend failed to produce a meta tile'); + } } else { diff --git a/lib/Tirex/Config.pm b/lib/Tirex/Config.pm index 4d0d238..549c637 100644 --- a/lib/Tirex/Config.pm +++ b/lib/Tirex/Config.pm @@ -72,6 +72,10 @@ sub parse_line { $confhash->{$prefix.$1} = $2; } + elsif ($line =~ /^([a-z0-9_]+)\s*=\s*"(\S*)"\s*$/) + { + $confhash->{$prefix.$1} = $2; + } elsif ($line =~ /^([a-z0-9_]+)\s+(.*?)\s*$/) { my $obj = $1;