[systemd-devel] Stopping services started by Systemd socket
Jérémy Rosen
jeremy.rosen at smile.fr
Tue Jan 23 08:28:36 UTC 2018
that's not really an answer to your question but...
have you looked at systemd-socket-proxyd ? it's a simple program that is
meant to be started by a socket and will redirect all traffic to another
local port.
Properly used it allows a traditional network daemon to be started on
demand. I won't go in the details, it's pretty well explained in the man
page.
Depending on why you are converting your software, it could be something
interesting to look at...
On 23/01/2018 08:18, Mantas Mikulėnas wrote:
> On Tue, Jan 23, 2018 at 3:06 AM, Liam Kelly <liamkelly17 at gmail.com> wrote:
>
>> How does Systemd communicate to socket activated application that the
>> connection has been closed? How can I modify my application to detect this
>> event if it cannot be configured to be closed automatically?
>>
>>
>>
>> We are trying to add network support to legacy code using Systemd sockets.
>> Using the 0pointer tutorials, we were able to configure a listening TCP
>> port and launch an instance of the application when a TCP connection came
>> in. The problem is that when the connection is closed, the service is still
>> running.
>>
>>
>>
>> The systemct list-units and netstat -tuapn outputs are what you would
>> expect when the connection is established
>>
>>
>>
>> systemctl list-units:
>>
>> myapp at 5-192.168.0.75:10001-192.168.210.102:19983.service loaded
>> active running My App
>>
>> netstat -tuapn:
>>
>> tcp 0 0 192.168.0.75:10001 192.168.210.102:19983
>> ESTABLISHED 1/init
>>
>> However, once the client closes the connection, the socket is closed and
>> removed, but the application is still running as a service:
>>
> It is no different from any other type of networked service. Whether you
> opened the socket yourself, or received it from a superserver, makes no
> difference.
>
> For example, if your program uses poll(), the kernel reports POLLHUP on a
> closed socket. If the program uses read() or recv(), 0 bytes indicates that
> the socket is closed. If the program uses simple stdio (inetd style), it's
> enough to check for EOF on reads from stdin.
>
>
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
SMILE <http://www.smile.eu/>
20 rue des Jardins
92600 Asnières-sur-Seine
*Jérémy ROSEN*
Architecte technique
Responsable de l'expertise Smile-ECS
email jeremy.rosen at smile.fr <mailto:jeremy.rosen at smile.fr>
phone +33141402967
url http://www.smile.eu
Twitter <https://twitter.com/GroupeSmile> Facebook
<https://www.facebook.com/smileopensource> LinkedIn
<https://www.linkedin.com/company/smile> Github
<https://github.com/Smile-SA>
Découvrez l’univers Smile, rendez-vous sur smile.eu
<http://smile.eu/?utm_source=signature&utm_medium=email&utm_campaign=signature>
eco Pour la planète, n'imprimez ce mail que si c'est nécessaire
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180123/af0c5b55/attachment-0001.html>
More information about the systemd-devel
mailing list