A port server is intended to be run as a daemon, for use by all processes
running on the host. It coordinates uses of network ports by anything using a
portpicker library. If you are using hosts as part of a test automation
cluster, each one should run a port server as a daemon. You should set the
PORTSERVER_ADDRESS=@unittest-portserver environment variable on all of your
test runners so that portpicker makes use of it.
A port server listens on a unix socket, reads a pid from a new connection,
tests the ports it is managing and replies with a port assignment port for
that pid. A port is only reclaimed for potential reassignment to another
process after the process it was originally assigned to has died. Processes
that need multiple ports can simply issue multiple requests and are guaranteed
they will each be unique.
1) Run one instance of this process on each of your unittest farm hosts.
2) Set the PORTSERVER_ADDRESS environment variable in your test runner
environment to let the portpicker library know to use a port server
rather than attempt to find ports on its own.
$ /path/to/portserver.py &
$ export PORTSERVER_ADDRESS=@unittest-portserver
$ # ... launch a bunch of unittest runners using portpicker ...