Systeme D

6.

Starting renderd with upstart.

The canonical instructions for setting up an OpenStreetMap tileserver suggest that you use init.d to start renderd on boot.

init.d is a bit gnarly and antiquated, however. upstart is much more pleasant; the config files are simpler and it's easier to chain one event off another. Which, as it happens, is what we want to do here; we want renderd to fire up once Postgres is running. Except that Postgres is started by an init.d script, not an upstart one. Gah.

So here's how to get it running:

Firstly, edit the Postgres startup script to emit init events on starting. You do this by adding initctl emit lines to /usr/share/postgresql-common/init.d-functions. For our purposes we only need to add

initctl emit postgresql-started

immediately after

do_ctl_all start "$1" "Starting PostgreSQL $1 database server"

But if you want to add the whole suite, this posting shows how to do it.

Next, we create /etc/init/renderd.conf as an upstart job:

# renderd

description "renderd"

start on postgresql-started
stop on runlevel [016]
respawn

setuid osm
setgid staff

script
  renderd -f -c /usr/local/etc/renderd.conf 1>>/var/log/renderd.log 2>>/var/log/renderd.log
end script

This will start renderd only after Postgres has started.

However, renderd needs to have a socket sitting within /var/run/renderd. We could in theory create that in renderd.conf, but I prefer that to run as the osm user, and not to allow the latter to create directories. So we add a second upstart job as /etc/init/renderd_socket.conf:

# renderd socket

description "Create renderd socket folder"

start on starting renderd

script
  mkdir /var/run/renderd
  chown osm /var/run/renderd
end script

Obviously, change osm if your user is called something else.

Reboot, and renderd should be up and running using upstart.

Posted on Tuesday 27 August 2013. Link.

Previous post: On my increasing exasperation with Markdown.