PORTSERVER.PY(1)
π PORTSERVER.PY β portserver.py, section 1 of the manual (User Commands) π
okay bestie, sit down, hydrate, and let me tell you about the little daemon that hands out port numbers like they're friendship bracelets π
β¨ NAME β¨
portserver.py β a server to hand out unused port numbers. that's it. that's the whole job. and it ATE. π
πΈ SYNOPSIS πΈ
usage: portserver.py [-h] [--portserver_static_pool PORTSERVER_STATIC_POOL]
[--portserver_address PORTSERVER_ADDRESS] [--verbose]
[--debug]
π¦ DESCRIPTION π¦
so the description section is basically the usage line again (the man page said it, not me), and then we get into the good stuff.
β¨ options β¨
here's the whole menu, no skips, no crumbs:
-h,--helpβ shows this help message and then dips. classic. π--portserver_static_pool PORTSERVER_STATIC_POOLβ a comma separated list ofN-Prange(s) of ports that you want it to manage, and yes the range is inclusive (both ends included, generous queen). π--portserver_address PORTSERVER_ADDRESS,--portserver_unix_socket_address PORTSERVER_ADDRESSβ the address of theAF_UNIXsocket it should listen on when you're on Unix (where a first@means a NUL), OR the name of the pipe on Windows (where a first@is the\\.\pipe\prefix). two flags, one argument name, same vibe. π«Ά--verboseβ turns on verbose messages. it will talk to you more. π£οΈ--debugβ turns on FULL debug messages. it will tell you everything. no secrets. π
π PORT SERVER π
okay so here's the lore. a port server is meant to be run as a daemon, for use by every single process running on the host. it coordinates the use of network ports by anything that's using a portpicker library. if you're using hosts as part of a test automation cluster, then every single one of those hosts should be running a port server as a daemon. and listen β you should set the PORTSERVER_ADDRESS=@unittest-portserver environment variable on ALL of your test runners so that portpicker actually makes use of it. iykyk. β¨
here's how it works, step by step, main character energy:
a port server listens on a unix socket, reads a pid from a new connection, tests the ports it is managing, and then replies with a port assignment port for that pid. π
and the important bit: a port is only reclaimed for potential reassignment to another process after the process it was originally assigned to has died. gone. deceased. resting. π
processes that need multiple ports can just... issue multiple requests, and they are guaranteed that each one will be unique. slay. no overlap, no drama. π
π TYPICAL USAGE π
- run one instance of this process on each of your unittest farm hosts. every single one. don't be stingy. π
- set the
PORTSERVER_ADDRESSenvironment variable in your test runner environment so the portpicker library knows to use a port server rather than trying to find ports all on its own. give it a little guidance bestie π§
$ /path/to/portserver.py &
$ export PORTSERVER_ADDRESS=@unittest-portserver
$ # ... launch a bunch of unittest runners using portpicker ...
like. look at that. three lines and your whole farm is vibing. π₯
ok real talk though: that & at the end of the first line is doing a LOT of work β it's what makes it a daemon situation, so don't forget it. π
that's the whole page, bestie β you're officially port-pilled. go forth and never guess a port number again. π
this iconic little number is portserver.py version 1.6.0, dated October 2024, and it lives in section 1 of the manual (User Commands). bye babes, see you in the socket π«Άβ¨π
π¦ where this page comes from
- debian trixie: python3-portpicker 1.6.0-2 Β· Apache-2.0
- ubuntu resolute: python3-portpicker 1.6.0-2 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms