Running a smart server
======================

Bazaar does not require a specialised server because it operates over HTTP, FTP
or SFTP.  There is an optional smart server that can be invoked over SSH, from
inetd, or in a dedicated mode.

Dumb servers
------------

We describe HTTP, FTP, SFTP and HTTP-WebDAV as "dumb" servers because they do
not offer any assistance to Bazaar.  If you make a Bazaar repository available
over any of these protocols, Bazaar will allow you to read it remotely.  Just
enter the URL to the branch in the Bazaar command you are running.::

    bzr log http://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev

Bazaar supports writing over FTP, SFTP and (via a plugin) over HTTP-WebDAV.

High-performance smart server
-----------------------------

The high-performance smart server (hpss) performs certain operations much faster
than dumb servers are capable of.  In future releases, the range of operations
that are improved by using the smart server will increase as we continue to
tune performance.

To maintain the highest security possible, the current
smart server provides read-only access by default.  To
enable read-write access, run it with ``--allow-writes``. When using
the SSH access method, bzr automatically runs with the
``--allow-writes`` option.

The alternative ways of configuring a smart server are explained below.

SSH
~~~

Using Bazaar over SSH requires no special configuration on the server; so long
as Bazaar is installed on the server you can use ``bzr+ssh`` URLs, e.g.::

    bzr log bzr+ssh://host/path/to/branch

If `bzr` is not installed system-wide on the server you may need to explicitly
tell the local `bzr` where to find the remote `bzr`::

    BZR_REMOTE_PATH=~/bin/bzr bzr log bzr+ssh://host/path/to/branch

The ``BZR_REMOTE_PATH`` environment variable adjusts how `bzr` will be
invoked on the remote system.  By default, just `bzr` will be invoked,
which requires the `bzr` executable to be on the default search path.  You can
also set this permanently per-location in ``locations.conf``.

Like SFTP, paths starting with ``~`` are relative to your home directory, e.g.
``bzr+ssh://example.com/~/code/proj``.  Additionally, paths starting with
``~user`` will be relative to that user's home directory.

inetd
~~~~~

This example shows how to run `bzr` with a dedicated user `bzruser`
for a shared repository in ``/srv/bzr/repo`` which has a branch at
``/srv/bzr/repo/branchname``.

Running a Bazaar server from inetd requires an inetd.conf entry::

    4155  stream  TCP  nowait  bzruser  /usr/bin/bzr /usr/bin/bzr serve --inet --directory=/srv/bzr/repo

When running client commands, the URL you supply is a `bzr://` URL relative to
the ``--directory`` option given in inetd.conf::

    bzr log bzr://host/branchname

If possible, paths starting with ``~`` and ``~user`` will be expanded as for
``bzr+ssh``.  Home directories outside the ``--directory`` specified to ``bzr
serve`` will not be accessible.

Dedicated
~~~~~~~~~

This mode has the same path and URL behaviour as the inetd mode.  To
run as a specific user, you should use ``su`` or login as that user.

This example runs bzr on its official port number of `4155` and listens on all
interfaces. This allows connections from anywhere in the world that can reach
your machine on port `4155`.

server::

    bzr serve --directory=/srv/bzr/repo

client::

    bzr log bzr://host/branchname

This example runs ``bzr serve`` on `localhost` port `1234`.

server::

    bzr serve --listen=localhost --port=1234 --directory=/srv/bzr/repo

client::

    bzr log bzr://localhost:1234/branchname

