[systemd-devel] What is the recommended way of announcing a TCP port?
John Ioannidis
systemd-devel at tla.org
Tue Jun 15 01:17:14 UTC 2021
I have an instanced service that gets started and stopped by another
service: *alice.service *runs the equivalent of *systemsctl start
alice at foo.service, systemctl start alice at bar.service, systemctl stop
alice at cat.service*, and so on.
Each of the instanced services runs a little http service so its status can
be monitored, metrics scraped, etc. The tcp port on which that service runs
is just whatever the kernel allocated. I want to export that port number so
other processes can find it and use it, for example, by doing the
equivalent of *systemctl list-units | grep alice@ *so they find which
instances are actually running, and then going about finding the
corresponding ports.
I can think of a number of ad hoc ways:
* they can write the port number in a file like /run/alice/foo.port,
/run/alice/bar.port, and whoever is interested can go read those files, in
the same way that we use .pid files.
* They can use systemd-notify to export it as "Status"
* Using a service discovery mechanism would be an overkill, especially
since whatever is actually talking to those ports is on the same host as
the services themselves, but that's also a possibility.
Is there a systemd-native way of accomplishing this? It would be nice if it
were possible to have user-defined properties that could be set with *systemctl
set-property*, but that is not the case.
Thanks
/ji
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210614/7a93d4fb/attachment.htm>
More information about the systemd-devel
mailing list