##// END OF EJS Templates
copies: compute the exact set of revision to walk...
copies: compute the exact set of revision to walk This change make the code clearer by removing the revision queue. It comes without very noticeable performance impact. However the simpler code will be easier to update in later changesets. revision: large amount; added files: large amount; rename small amount; c3b14617fbd7 9ba6ab77fd29 before: ! wall 1.430082 comb 1.430000 user 1.390000 sys 0.040000 (median of 10) after: ! wall 1.405192 comb 1.410000 user 1.390000 sys 0.020000 (median of 10) revision: large amount; added files: small amount; rename small amount; c3b14617fbd7 f650a9b140d2 before: ! wall 1.971366 comb 1.970000 user 1.950000 sys 0.020000 (median of 10) after: ! wall 1.892541 comb 1.890000 user 1.870000 sys 0.020000 (median of 10) revision: large amount; added files: large amount; rename large amount; 08ea3258278e d9fa043f30c0 before: ! wall 0.252594 comb 0.250000 user 0.240000 sys 0.010000 (median of 38) after: ! wall 0.240075 comb 0.240000 user 0.240000 sys 0.000000 (median of 40) revision: small amount; added files: large amount; rename large amount; df6f7a526b60 a83dc6a2d56f before: ! wall 0.013100 comb 0.010000 user 0.010000 sys 0.000000 (median of 226) after: ! wall 0.013247 comb 0.010000 user 0.010000 sys 0.000000 (median of 223) revision: small amount; added files: large amount; rename small amount; 4aa4e1f8e19a 169138063d63 before: ! wall 0.001633 comb 0.000000 user 0.000000 sys 0.000000 (median of 1000) after: ! wall 0.001670 comb 0.000000 user 0.000000 sys 0.000000 (median of 1000) revision: small amount; added files: small amount; rename small amount; 4bc173b045a6 964879152e2e before: ! wall 0.000078 comb 0.000000 user 0.000000 sys 0.000000 (median of 11984) after: ! wall 0.000119 comb 0.000000 user 0.000000 sys 0.000000 (median of 7982) revision: medium amount; added files: large amount; rename medium amount; c95f1ced15f2 2c68e87c3efe before: ! wall 0.207093 comb 0.210000 user 0.210000 sys 0.000000 (median of 47) after: ! wall 0.201551 comb 0.200000 user 0.200000 sys 0.000000 (median of 48) revision: medium amount; added files: medium amount; rename small amount; d343da0c55a8 d7746d32bf9d before: ! wall 0.038462 comb 0.040000 user 0.040000 sys 0.000000 (median of 100) after: ! wall 0.036578 comb 0.030000 user 0.030000 sys 0.000000 (median of 100) Differential Revision: https://phab.mercurial-scm.org/D7076

File last commit:

r23399:fd5247a8 default
r43593:83bb1e89 default
Show More
README.rst
144 lines | 5.1 KiB | text/x-rst | RstLexer
Gregory Szorc
docker: add Docker files for running an Apache mod_wsgi server...
r23399 ====================
Apache Docker Server
====================
This directory contains code for running a Mercurial hgweb server via
mod_wsgi with the Apache HTTP Server inside a Docker container.
.. important::
This container is intended for testing purposes only: it is
**not** meant to be suitable for production use.
Building Image
==============
The first step is to build a Docker image containing Apache and mod_wsgi::
$ docker build -t hg-apache .
.. important::
You should rebuild the image whenever the content of this directory
changes. Rebuilding after pulling or when you haven't run the container
in a while is typically a good idea.
Running the Server
==================
To run the container, you'll execute something like::
$ docker run --rm -it -v `pwd`/../../..:/var/hg/source -p 8000:80 hg-apache
If you aren't a Docker expert:
* ``--rm`` will remove the container when it stops (so it doesn't clutter
your system)
* ``-i`` will launch the container in interactive mode so stdin is attached
* ``-t`` will allocate a pseudo TTY
* ``-v src:dst`` will mount the host filesystem at ``src`` into ``dst``
in the container. In our example, we assume you are running from this
directory and use the source code a few directories up.
* ``-p 8000:80`` will publish port ``80`` on the container to port ``8000``
on the host, allowing you to access the HTTP server on the host interface.
* ``hg-apache`` is the container image to run. This should correspond to what
we build with ``docker build``.
.. important::
The container **requires** that ``/var/hg/source`` contain the Mercurial
source code.
Upon start, the container will attempt an install of the source in that
directory. If the architecture of the host machine doesn't match that of
the Docker host (e.g. when running Boot2Docker under OS X), Mercurial's
Python C extensions will fail to run. Be sure to ``make clean`` your
host's source tree before mounting it in the container to avoid this.
When starting the container, you should see some start-up actions (including
a Mercurial install) and some output saying Apache has started::
Now if you load ``http://localhost:8000/`` (or whatever interface Docker
is using), you should see hgweb running!
For your convenience, we've created an empty repository available at
``/repo``. Feel free to populate it with ``hg push``.
Customizing the Server
======================
By default, the Docker container installs a basic hgweb config and an
empty dummy repository. It also uses some reasonable defaults for
mod_wsgi.
Customizing the WSGI Dispatcher And Mercurial Config
----------------------------------------------------
By default, the Docker environment installs a custom ``hgweb.wsgi``
file (based on the example in ``contrib/hgweb.wsgi``). The file
is installed into ``/var/hg/htdocs/hgweb.wsgi``.
A default hgweb configuration file is also installed. The ``hgwebconfig``
file from this directory is installed into ``/var/hg/htdocs/config``.
You have a few options for customizing these files.
The simplest is to hack up ``hgwebconfig`` and ``entrypoint.sh`` in
this directory and to rebuild the Docker image. This has the downside
that the Mercurial working copy is modified and you may accidentally
commit unwanted changes.
The next simplest is to copy this directory somewhere, make your changes,
then rebuild the image. No working copy changes involved.
The preferred solution is to mount a host file into the container and
overwrite the built-in defaults.
For example, say we create a custom hgweb config file in ``~/hgweb``. We
can start the container like so to install our custom config file::
$ docker run -v ~/hgweb:/var/hg/htdocs/config ...
You can do something similar to install a custom WSGI dispatcher::
$ docker run -v ~/hgweb.wsgi:/var/hg/htdocs/hgweb.wsgi ...
Managing Repositories
---------------------
Repositories are served from ``/var/hg/repos`` by default. This directory
is configured as a Docker volume. This means you can mount an existing
data volume container in the container so repository data is persisted
across container invocations. See
https://docs.docker.com/userguide/dockervolumes/ for more.
Alternatively, if you just want to perform lightweight repository
manipulation, open a shell in the container::
$ docker exec -it <container> /bin/bash
Then run ``hg init``, etc to manipulate the repositories in ``/var/hg/repos``.
mod_wsgi Configuration Settings
-------------------------------
mod_wsgi settings can be controlled with the following environment
variables.
WSGI_PROCESSES
Number of WSGI processes to run.
WSGI_THREADS
Number of threads to run in each WSGI process
WSGI_MAX_REQUESTS
Maximum number of requests each WSGI process may serve before it is
reaped.
See https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess
for more on these settings.
.. note::
The default is to use 1 thread per process. The reason is that Mercurial
doesn't perform well in multi-threaded mode due to the GIL. Most people
run a single thread per process in production for this reason, so that's
what we default to.