Re: [systemd-devel] What is the recommended way of announcing a TCP port?

2021-06-25 Thread John Ioannidis
On Tue, Jun 15, 2021 at 1:45 AM Mantas Mikulėnas  wrote:

> If you only care about processes on the same system – why not put the
> actual socket in /run, as an AF_UNIX socket? That's mostly what /run is for.
>

I thought of that, but Prometheus cannot scrape AF_UNIX addresses.

Thanks though,

/ji


> On Tue, Jun 15, 2021, 04:18 John Ioannidis  wrote:
>
>> I have an instanced service that gets started and stopped by another
>> service: *alice.service *runs the equivalent of *systemsctl start
>> alice@foo.service, systemctl start alice@bar.service, systemctl stop
>> alice@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
>> ___
>> systemd-devel mailing list
>> systemd-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>>
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] What is the recommended way of announcing a TCP port?

2021-06-25 Thread John Ioannidis
On Mon, Jun 14, 2021 at 9:29 PM Kevin P. Fleming  wrote:

> You might consider having systemd itself create the listening sockets
> and then pass them into the service; if you did that, then systemd
> would already know the port number that was allocated for the socket.
>
>
I can't; a .socket unit gets activated, and subsequently starts its
corresponding service, when the first connection is made. The primary
purpose of the service is not to serve data over that socket; the socket is
there for scraping metrics.

Thanks though,

/ji

> On Mon, Jun 14, 2021 at 9:17 PM John Ioannidis 
> wrote:
> >
> > I have an instanced service that gets started and stopped by another
> service: alice.service runs the equivalent of systemsctl start
> alice@foo.service, systemctl start alice@bar.service, systemctl stop
> alice@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
> > ___
> > systemd-devel mailing list
> > systemd-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] What is the recommended way of announcing a TCP port?

2021-06-14 Thread Mantas Mikulėnas
If you only care about processes on the same system – why not put the
actual socket in /run, as an AF_UNIX socket? That's mostly what /run is for.

On Tue, Jun 15, 2021, 04:18 John Ioannidis  wrote:

> I have an instanced service that gets started and stopped by another
> service: *alice.service *runs the equivalent of *systemsctl start
> alice@foo.service, systemctl start alice@bar.service, systemctl stop
> alice@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
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] What is the recommended way of announcing a TCP port?

2021-06-14 Thread Kevin P. Fleming
You might consider having systemd itself create the listening sockets
and then pass them into the service; if you did that, then systemd
would already know the port number that was allocated for the socket.

On Mon, Jun 14, 2021 at 9:17 PM John Ioannidis  wrote:
>
> I have an instanced service that gets started and stopped by another service: 
> alice.service runs the equivalent of systemsctl start alice@foo.service, 
> systemctl start alice@bar.service, systemctl stop alice@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
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel