##// END OF EJS Templates
packaging: support building Inno installer with PyOxidizer...
packaging: support building Inno installer with PyOxidizer We want to start distributing Mercurial on Python 3 on Windows. PyOxidizer will be our vehicle for achieving that. This commit implements basic support for producing Inno installers using PyOxidizer. While it is an eventual goal of PyOxidizer to produce installers, those features aren't yet implemented. So our strategy for producing Mercurial installers is similar to what we've been doing with py2exe: invoke a build system to produce files then stage those files into a directory so they can be turned into an installer. We had to make significant alterations to the pyoxidizer.bzl config file to get it to produce the files that we desire for a Windows install. This meant differentiating the build targets so we can target Windows specifically. We've added a new module to hgpackaging to deal with interacting with PyOxidizer. It is similar to pyexe: we invoke a build process then copy files to a staging directory. Ideally these extra files would be defined in pyoxidizer.bzl. But I don't think it is worth doing at this time, as PyOxidizer's config files are lacking some features to make this turnkey. The rest of the change is introducing a variant of the Inno installer code that invokes PyOxidizer instead of py2exe. Comparing the Python 2.7 based Inno installers with this one, the following changes were observed: * No lib/*.{pyd, dll} files * No Microsoft.VC90.CRT.manifest * No msvc{m,p,r}90.dll files * python27.dll replaced with python37.dll * Add vcruntime140.dll file The disappearance of the .pyd and .dll files is acceptable, as PyOxidizer has embedded these in hg.exe and loads them from memory. The disappearance of the *90* files is acceptable because those provide the Visual C++ 9 runtime, as required by Python 2.7. Similarly, the appearance of vcruntime140.dll is a requirement of Python 3.7. Differential Revision: https://phab.mercurial-scm.org/D8473
Gregory Szorc -
r45256:9965d6c3 default
Show More
Name Size Modified Last Commit Author
/ contrib / docker / apache-server
Dockerfile Loading ...
README.rst Loading ...
entrypoint.sh Loading ...
hgwebconfig Loading ...
vhost.conf Loading ...

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.