[systemd-devel] ListenStream=0
Albert Strasheim
fullung at gmail.com
Mon Apr 4 07:44:57 PDT 2011
Hello
On Mon, Apr 4, 2011 at 4:32 PM, Lennart Poettering
<lennart at poettering.net> wrote:
> On Mon, 04.04.11 07:13, Albert Strasheim (fullung at gmail.com) wrote:
>> Hello all
>> I just tried to start a socket unit with ListenStream=0 in the
>> configuration, but this yields the following error:
>> Failed to issue method call: Unit zero.socket failed to load: Invalid
>> argument. See system logs and 'systemctl status' for details.
>> I would expect that it would simply bind to any free port.
>> Bug or feature?
> We validate all input data, and to me it appeared as if port 0 would be
> a not so useful feature.
> But uh, I can be convinced to allow port == 0. Do you have a good
> usecase for this? How do you determine the port number actually used? If
> we allow port 0 we would have to add an interface so that clients can
> query what was actually used, or not?
Our use-case looks something like this:
We are running a bunch of services across multiple machines.
Depending on the number of cores/memory/etc. in a machine, it will be
configured to run a variable number of instances of a particular
service.
Each instance will announce itself to the rest of the machines using
multicast or some kind of central registry.
Part of this announcement contains the IP address and port where it
can be contacted, so this port can be dynamically assigned.
In this kind of scenario it's nice to not have to worry about the
specifics of the ports, or about keeping port ranges for different
services separated.
I think you can leave the problem of which port was actually assigned
to someone else for now. The service itself can discover its port
number using getsockname.
This paradigm is supported in various programming languages, including
Go, Erlang, etc.
Regards
Albert
More information about the systemd-devel
mailing list