========
 Server
========

Run :program:`xdserver` to allow clients to access a set of
databases stored in a directory.


Prepare a directory for data storage
====================================

Create a directory to store Durus database files.

Consider using the :file:`.xdserver` extension to help you remember
that it contains Durus database files.

.. code-block:: console

    $ mkdir appdata.xdserver


Starting a server
=================

Run :program:`xdserver`, giving it the name of the directory to
serve from.  The program will respond with the host and port it is
listening on:

.. code-block:: console

    $ xdserver appdata.xdserver
    Listening on 127.0.0.1:22972

Override the host and/or port by using :option:`--host` and
:option:`--port`.  For example, you can listen on all network
interfaces at port 3333:

.. code-block:: console

    $ xdserver --host=0.0.0.0 --port=3333 appdata.xdserver
    Listening on 0.0.0.0:3333

Quiet log output by setting :option:`--loglevel`:

.. code-block:: console

    $ xdserver --loglevel=100

.. todo::

   Replace :option:`--loglevel` with :option:`--verbose` and
   :option:`--quiet`.


Stopping a server
=================

Press :kbd:`Control-C` where xdserver is running.  xdserver will
disconnect all connected clients and stop listening for new
connections.


Running a server in the background
==================================

.. todo::

   Describe methods for running a server in the background.
