Configuration

I’ve built several large server products, like the Xitami web server that was popular in the late ’90s, and the OpenAMQ messaging server. Getting configuration easy and obvious was a large part of making these servers fun to use.

We typically aim to solve a number of problems:

  • Ship default configuration files with the product.

  • Allow users to add custom configuration files that are never overwritten.

  • Allow users to configure from the command line.

And then layer these one on top of the other, so command-line settings override custom settings, which override default settings. It can be a lot of work to do this right. For FileMQ, I’ve taken a somewhat simpler tack: all configuration is done from the API.

This is how we start and configure the server, for example:

server = fmq_server_new ();
fmq_server_configure (server, "server_test.cfg");
fmq_server_publish (server, "./fmqroot/send", "/");
fmq_server_publish (server, "./fmqroot/logs", "/logs");
fmq_server_bind (server, "tcp://*:5670");

We do use a specific format for the config files—the ZeroMQ Property Language (ZPL), a minimalist syntax that we started using for ØMQ “devices” a few years ago, but which works well for any server:

# Configure server for plain access # server monitor = 1 # Check mount points heartbeat = 1 # Heartbeat to clients publish location = ./fmqroot/logs virtual = /logs security echo = I: use guest/guest to login to server # These are SASL mechanisms we accept anonymous = 0 plain = 1 account ...

Get ZeroMQ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.