Overv / openstreetmap-tile-server

Docker file for a minimal effort OpenStreetMap tile server
Apache License 2.0
1.23k stars 486 forks source link

mapnik.xml file is empty when using custom style #355

Closed muellercornelius closed 1 year ago

muellercornelius commented 1 year ago

Hi Guys ;) I have no clue anymore...

When I just do the import and run it everything works flawlessly but as soon as i use a "custom" style it does not work anymore ;(. I am pretty sure I am missing something but i dont know what...

The error message is:

ERROR **: 16:45:53.403: An error occurred while loading the map layer 'default': XML document not well formed:
Document is empty at line 1 of '/home/renderer/src/openstreetmap-carto/mapnik.xml'

and yes that is true... but why is it empty?

My steps:

After that I run it with:

docker run 
    -e NAME_LUA=openstreetmap-carto.lua 
    -e NAME_STYLE=openstreetmap-carto.style 
    -e NAME_MML=project.mml 
    -e NAME_SQL=indexes.sql 
    -v osm-data:/data/database/ 
    -v /home/osm/openstreetmap-carto:/data/style/ 
    overv/openstreetmap-tile-server 
    run

Tja and all those steps leave me with an empty mapnik.xml file...

Does anyone know what i forgot?

Thank you for every help.

PS: Here is the complete output of the run command:

root@localhost:/home/osm/openstreetmap-carto# docker run -e NAME_LUA=openstreetmap-carto.lua -e NAME_STYLE=openstreetmap-carto.style -e NAME_MML=project.mml -e NAME_SQL=indexes.sql -v osm-data:/data/database/ -v /home/osm/openstreetmap-carto:/data/style/ overv/openstreetmap-tile-server run
++ ls -A /data/style/
+ '[' '!' '.dockerignore
.editorconfig
.git
.gitattributes
.github
.gitignore
CARTOGRAPHY.md
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
DOCKER.md
Dockerfile
Dockerfile.db
Dockerfile.import
INSTALL.md
LICENSE.txt
README.md
RELEASES.md
USECASES.md
data
docker-compose.yml
external-data.yml
indexes.sql
indexes.yml
mapnik.xml
openstreetmap-carto.lua
openstreetmap-carto.style
patterns
preview.png
project.mml
road-colors.yaml
scripts
style
symbols
test.txt' ']'
+ '[' '!' -f /data/style/mapnik.xml ']'
+ '[' run == import ']'
+ '[' run == run ']'
+ rm -rf /tmp/hsperfdata_root
+ '[' -f /data/database/PG_VERSION ']'
+ '[' -f /nodes/flat_nodes.bin ']'
+ '[' -f /data/tiles/data.poly ']'
+ '[' -f /data/tiles/planet-import-complete ']'
+ '[' -f /data/tiles/planet-import-complete ']'
+ '[' -f /data/database/planet-import-complete ']'
+ cp /data/database/planet-import-complete /data/tiles/planet-import-complete
+ chown -R postgres: /var/lib/postgresql/ /data/database/postgres/
+ '[' '' == enabled ']'
+ '[' '' == 1 ']'
+ createPostgresConfig
+ cp /etc/postgresql/14/main/postgresql.custom.conf.tmpl /etc/postgresql/14/main/conf.d/postgresql.custom.conf
+ sudo -u postgres echo 'autovacuum = on'
+ cat /etc/postgresql/14/main/conf.d/postgresql.custom.conf
# Suggested minimal settings from
# https://ircama.github.io/osm-carto-tutorials/tile-server-ubuntu/

shared_buffers = 128MB
min_wal_size = 1GB
# max_wal_size = 2GB # Overridden below
maintenance_work_mem = 256MB

# Suggested settings from
# https://github.com/openstreetmap/chef/blob/master/roles/tile.rb#L38-L45

max_connections = 250
temp_buffers = 32MB
work_mem = 128MB
wal_buffers = 1024kB
wal_writer_delay = 500ms
commit_delay = 10000
# checkpoint_segments = 60 # unrecognized in psql 10.7.1
max_wal_size = 2880MB
random_page_cost = 1.1
track_activity_query_size = 16384
autovacuum_vacuum_scale_factor = 0.05
autovacuum_analyze_scale_factor = 0.02

listen_addresses = '*'
autovacuum = on
+ service postgresql start
 * Starting PostgreSQL 14 database server
   ...done.
+ service apache2 restart
 * Restarting Apache httpd web server apache2
[Thu Jan 12 16:45:51.996851 2023] [so:warn] [pid 64:tid 140646807861120] AH01574: module tile_module is already loaded, skipping
[Thu Jan 12 16:45:51.999335 2023] [tile:warn] [pid 64:tid 140646807861120] Could not determine host name of server to configure tile-json request. Using localhost instead
[Thu Jan 12 16:45:51.999844 2023] [tile:notice] [pid 64:tid 140646807861120] Loading tile config default at /tile/  for zooms 0 - 20 from tile directory /var/cache/renderd/tiles  with extension .png and mime type image/png
[Thu Jan 12 16:45:52.000428 2023] [tile:notice] [pid 64:tid 140646807861120] Loading tile config default at /tile/ for zooms 0 - 20 from tile directory /var/cache/renderd/tiles with extension .png and mime type image/png
[Thu Jan 12 16:45:52.000816 2023] [tile:notice] [pid 64:tid 140646807861120] Loading tile config default at /tile/  for zooms 0 - 20 from tile directory /var/cache/renderd/tiles  with extension .png and mime type image/png
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
[Thu Jan 12 16:45:52.017337 2023] [so:warn] [pid 64:tid 140646807861120] AH01574: module tile_module is already loaded, skipping
   ...done.
+ setPostgresPassword
+ sudo -u postgres psql -c 'ALTER USER renderer PASSWORD '\''renderer'\'''
ALTER ROLE
+ sed -i -E 's/num_threads=[0-9]+/num_threads=4/g' /etc/renderd.conf
+ '[' disabled == enabled ']'
+ '[' disabled == 1 ']'
+ trap stop_handler SIGTERM
+ child=130
+ wait 130
+ sudo -u renderer renderd -f -c /etc/renderd.conf
** INFO: 16:45:53.177: Rendering daemon started
** INFO: 16:45:53.178: Initialising request_queue
** INFO: 16:45:53.179: Parsing section renderd
** INFO: 16:45:53.179: Parsing render section 0
** INFO: 16:45:53.179: Parsing section mapnik
** INFO: 16:45:53.180: Parsing section default
** INFO: 16:45:53.180: config renderd: unix socketname=/run/renderd/renderd.sock
** INFO: 16:45:53.180: config renderd: num_threads=4
** INFO: 16:45:53.180: config renderd: num_slaves=0
** INFO: 16:45:53.181: config renderd: tile_dir=/var/cache/renderd/tiles
** INFO: 16:45:53.181: config renderd: stats_file=/run/renderd/renderd.stats
** INFO: 16:45:53.181: config mapnik:  plugins_dir=/usr/lib/mapnik/3.1/input
** INFO: 16:45:53.181: config mapnik:  font_dir=/usr/share/fonts
** INFO: 16:45:53.182: config mapnik:  font_dir_recurse=1
** INFO: 16:45:53.182: config renderd(0): Active
** INFO: 16:45:53.182: config renderd(0): unix socketname=/run/renderd/renderd.sock
** INFO: 16:45:53.182: config renderd(0): num_threads=4
** INFO: 16:45:53.183: config renderd(0): tile_dir=/var/cache/renderd/tiles
** INFO: 16:45:53.183: config renderd(0): stats_file=/run/renderd/renderd.stats
** INFO: 16:45:53.183: config map 0:   name(default) file(/home/renderer/src/openstreetmap-carto/mapnik.xml) uri(/tile/) htcp() host(localhost)
** INFO: 16:45:53.184: Initialising unix server socket on /run/renderd/renderd.sock
** INFO: 16:45:53.184: Renderd is using mapnik version 3.1.0
** INFO: 16:45:53.398: Running in foreground mode...
** INFO: 16:45:53.400: Loading parameterization function for

** (process:131): ERROR **: 16:45:53.401: An error occurred while loading the map layer 'default': XML document not well formed:
Document is empty at line 1 of '/home/renderer/src/openstreetmap-carto/mapnik.xml'
** INFO: 16:45:53.400: Loading parameterization function for
** INFO: 16:45:53.402: Loading parameterization function for
** INFO: 16:45:53.403: Loading parameterization function for

** (process:131): ERROR **: 16:45:53.403: An error occurred while loading the map layer 'default': XML document not well formed:
Document is empty at line 1 of '/home/renderer/src/openstreetmap-carto/mapnik.xml'

** (process:131): ERROR **: 16:45:53.403: An error occurred while loading the map layer 'default': XML document not well formed:
Document is empty at line 1 of '/home/renderer/src/openstreetmap-carto/mapnik.xml'

** (process:131): ERROR **: 16:45:53.404: An error occurred while loading the map layer 'default': XML document not well formed:
Document is empty at line 1 of '/home/renderer/src/openstreetmap-carto/mapnik.xml'
Istador commented 1 year ago

Besides the test.txt it also contains a mapnik.xml which is not part of the osm-carto project by default, so that screenshot is from after running additional steps after cloning.

Try to delete that file, the run.sh should automatically build the file again if missing. Have a look at the output of the following run. If the mapnik.xml is empty, that looks like there was an error compiling it from the project.mml which might be in the log of it then (if the file already exists, it doesn't try to compile it again and therefore doesn't log an error message from that step).


Possible cause: This image uses a specific older version (v5.4.0) of osm-carto that is known to work, and is also adjusting some fonts.

https://github.com/Overv/openstreetmap-tile-server/blob/10571b77b756bea8046f59de08d27f84c4faffe9/Dockerfile#L14-L20

Cloning it yourself will install a newer version that might be incompatible, or is missing the font adjustments.

kiddikai commented 1 year ago

I ran into the exact same problem and managed to fix it by upgrading carto (the processor that compiles openstreetmap-carto into a single mapnik.xml).

As @Istador pointed out, this project uses outdated openstreetmap-carto@5.4.0. This works fine with carto@0.18.2 which is also outdated. However, you cannot compile a more recent version of openstreetmap-carto because it is using features that carto@0.18.2 does not support. Instead, when running run.sh, carto crashes. The error is not caught and you are left with an empty mapnik.xml:

carto ${NAME_MML:-project.mml} > mapnik.xml

By upgrading carto to its current version 1.2.0, I can now use openstreetmap-carto 5.4.0 as well as the latest release 5.7.0.

muellercornelius commented 1 year ago

thank you very much both of you. That helped a lot. I got it working with the old openstreetmap-carto. But I am looking forward to use the recent one. Thank you ;)

kiddikai commented 1 year ago

@muellercornelius You are welcome to try out my patch. It enables you to use the latest release of openstreetmap-carto.

On another note, please reopen this issue. It is not solved unless the pull request is merged. Thank you!