Rendering/extracting 来自 metatiles 的 .png 图块:"Failed to read cmd on fd 4" (OSX)

Rendering/extracting .png tiles from metatiles: "Failed to read cmd on fd 4" (OSX)

我正在尝试 运行 使用 mapnik 和 mod_tile 的图块服务器。现在,我能够从 (zoom,x,y)-requests 生成元图片,但我不明白为什么从来没有真正提供过图块(如 png)。原因似乎是以下错误:Failed to read cmd on FD 4

我已经使用此工具检查元图块是否符合我的要求,一切看起来都很好。

为了以防万一,这里是我所拥有的 debug/info:

$ sudo -u postgres renderd -f -c /usr/local/etc/renderd.conf
renderd[16811] <Info>: config renderd: unix socketname=/var/run/renderd/renderd.sock
renderd[16811] <Info>: config renderd: num_threads=4
renderd[16811] <Info>: config renderd: num_slaves=0
renderd[16811] <Info>: config renderd: tile_dir=/var/lib/mod_tile
renderd[16811] <Info>: config renderd: stats_file=/var/run/renderd/renderd.stats
renderd[16811] <Info>: config mapnik:  plugins_dir=/usr/local/lib/mapnik/input
renderd[16811] <Info>: config mapnik:  font_dir=/usr/local/lib/mapnik/fonts
renderd[16811] <Info>: config mapnik:  font_dir_recurse=1
renderd[16811] <Info>: config renderd(0): Active
renderd[16811] <Info>: config renderd(0): unix socketname=/var/run/renderd/renderd.sock
renderd[16811] <Info>: config renderd(0): num_threads=4
renderd[16811] <Info>: config renderd(0): tile_dir=/var/lib/mod_tile
renderd[16811] <Info>: config renderd(0): stats_file=/var/run/renderd/renderd.stats
renderd[16811] <Info>: config map 0:   name(default) file(openstreetmap-carto/mapnik.xml) uri(/osm_tiles/) htcp() host(localhost)
renderd[16811] <Info>: Initialising unix server socket on /var/run/renderd/renderd.sock
renderd[16811] <Debug>: Created server socket 3
renderd[16811] <Info>: Renderd is using mapnik version 3.0.13  
...
...
Running in foreground mode...
renderd[16811] <Debug>: Starting stats thread
debug: init_storage_backend: initialising file storage backend at: /var/lib/mod_tile
debug: init_storage_backend: initialising file storage backend at: /var/lib/mod_tile
renderd[16811] <Info>: Loading parameterization function for
debug: init_storage_backend: initialising file storage backend at: /var/lib/mod_tile
debug: init_storage_backend: initialising file storage backend at: /var/lib/mod_tile
renderd[16811] <Info>: Loading parameterization function for
renderd[16811] <Info>: Loading parameterization function for
renderd[16811] <Info>: Loading parameterization function for
Mapnik LOG> 2017-06-10 04:07:37: warning: unable to find face-name 'unifont Medium' in FontSet 'fontset-0'

这种特殊字体无法加载,但我很确定它只是我的 mapnik.xml 文件中的一个副本(它带有一个大字体和一个小字体 'u')。启动渲染守护进程后的最终输出是(4次):

Jun 10 04:07:39  renderd[16811] <Debug>: Using web Mercator projection settings

然后我清理所有内容并重新启动 apache:

$ rm -rf /var/lib/mod_tile/default/*
$ sudo bash -c 'echo -e "\c" > /var/log/apache2/error-mode_tile.log'
$ sudo apachectl -k restart

最后我尝试加载一个特定的图块,比如 tile(8,251,160) 使用我的本地地址:localhost/osm_tiles/8/251/160.png。呈现守护程序提供以下调试输出:

renderd[17950] <Debug>: DEBUG: Got incoming connection, fd 4, number 1
renderd[17950] <Debug>: DEBUG: Got incoming request with protocol version 2
renderd[17950] <Debug>: DEBUG: Got command RenderPrio fd(4) xml(default), z(8), x(251), y(160), mime(image/png), options()
renderd[17950] <Debug>: DEBUG: START TILE default 8 248-255 160-167, new metatile
renderd[17950] <Debug>: Rendering projected coordinates 8 248 160 -> 18785164.071375|-6261721.357125 20037508.342800|-5009377.085700 to a 8 x 8 tile
renderd[17950] <Debug>: DEBUG: DONE TILE default 8 248-255 160-167 in 6.177 seconds
debug: Creating and writing a metatile to /var/lib/mod_tile/default/8/0/0/0/250/128.meta
renderd[17950] <Debug>: DEBUG: Sending render cmd(3 default 8/251/160) with protocol version 2 to fd 4
renderd[17950] <Info>: DEBUG: Failed to read cmd on fd 4
renderd[17950] <Debug>: DEBUG: Connection 0, fd 4 closed, now 0 left

这里是问题出现的地方"Failed to read cmd on fd 4",我试图在网上寻找这个但找不到明确的答案。这是相应的 apache 跟踪:

[core:trace5] [pid 18636] protocol.c(643): [client ::1:56548] Request received from client: GET /osm_tiles/8/251/160.png HTTP/1.1
...
[tile:debug] [pid 18636] ./src/mod_tile.c(1306): [client ::1:56548] tile_translate: testing baseuri(/osm_tiles/) name(default) extension(png)
[tile:debug] [pid 18636] ./src/mod_tile.c(1352): [client ::1:56548] tile_translate: request for default was 251 160 256
[tile:debug] [pid 18636] ./src/mod_tile.c(324): [client ::1:56548] get_storage_backend: Retrieving storage back end for tile layer 0 in pool 7fb684031628 and thread -1075362880
[tile:debug] [pid 18636] ./src/mod_tile.c(338): [client ::1:56548] get_storage_backend: No storage backends for this lifecycle 7fb684031628, creating it in thread -1075362880
[tile:debug] [pid 18636] ./src/mod_tile.c(353): [client ::1:56548] get_storage_backend: No storage backend in current lifecycle 7fb684031628 in thread -1075362880 for current tile layer 0
[tile:debug] [pid 18636] ./src/mod_tile.c(1391): [client ::1:56548] tile_translate: op(tile_serve) xml(default) mime(image/png) z(8) x(251) y(160)
[tile:info] [pid 18636] [client ::1:56548] tile_storage_hook: handler(tile_serve), uri(/osm_tiles/8/251/160.png)
[tile:debug] [pid 18636] ./src/mod_tile.c(374): [client ::1:56548] tile_state: determined state of default 251 160 8 on store 7fb683502f90: Tile size: 317572, expired: 0 created: 1497065892
[tile:debug] [pid 18335] ./src/mod_tile.c(176): [client ::1:56547] Connecting to renderd on Unix socket /var/run/renderd/renderd.sock
[tile:info] [pid 18335] [client ::1:56547] Requesting style(default) z(8) x(251) y(160) from renderer with priority 5
[authz_core:debug] [pid 18636] mod_authz_core.c(834): [client ::1:56548] AH01628: authorization result: granted (no directives)
[core:trace3] [pid 18636] request.c(296): [client ::1:56548] request authorized without authentication by access_checker_ex hook: /osm_tiles/8/251/160.png

然后就结束了,没有其他事情发生。我真的对此了解不多,所以欢迎任何建议。如果有帮助,我也可以提供我的配置文件。

"Failed to read cmd on fd" 消息实际上并不是错误,它实际上只是一些调试日志记录。请参阅 https://github.com/openstreetmap/mod_tile/issues/77 for details about the change that introduced it. If you just want to "not see that message", then the version that I forked from that (for some other changes) https://github.com/SomeoneElseOSM/mod_tile 的顶部可能会有用,因为我在那里删除了该消息。

但是,这不会解决您的根本问题(获得工作的 tile 服务器)- 为此,我建议您要么找到 MacOS 的 "soup to nuts" 安装指南,要么开始,这样您就可以了解事物如何组合在一起,Ubuntu VM 中的磁贴服务器。

以防万一有人遇到保存问题。问题来自 apache (mod_hfs_apple.so) 默认加载的 apple 模块。为了解决这个问题,我只是进入 /etc/apache2/httpd.conf 并评论了以下行: LoadModule hfs_apple_module libexec/apache2/mod_hfs_apple.so

这个hack对我来说不是很满意,目标是纠正mod_tile。看起来需要修复的部分位于 mod_tile.c:1643:

static void register_hooks(__attribute__((unused)) apr_pool_t *p)
{
   ...
   ap_hook_translate_name(tile_translate, NULL, NULL, APR_HOOK_MIDDLE);
   ...
}

现在我没有勇气找到真正的解决方案,只是快速浏览了一下,我发现这条奇怪的线可能会给任何试图阅读的人(例如,mod_hfs_apple)带来问题要求。在 mod_tile.c:1278:

static int tile_translate(request_rec *r)
{
   ...
               r->filename = NULL; 
   ...
}