bstarynk / helpcovid

a C++ free software web application (GPLv3+, Linux) to organize people helping other neighbours in Covid pandemics
GNU General Public License v3.0
2 stars 2 forks source link

Enable the conventional LISTEN_FDS mechanism #32

Open jdebp opened 4 years ago

jdebp commented 4 years ago

Per https://unix.stackexchange.com/a/578832/5132 the program should be capable of taking the listening socket as an already open file descriptor set up by a service manager, e.g. a systemd socket unit with Accept=No, the nosh toolset, or even inetd in its wait mode. The former two examples support the LISTEN_FDS mechanism, which allow the program to know that this is happening and what file descriptor(s) are open listening socket file descriptors.

This unfortunately involves a change to the underlying http utility library, which (despite this being common practice because of inetd) does not apparently have a method for doing this.

The aforelinked StackExchange answer has my code for implementing the part of the LISTEN_FDS mechanism that the service program needs to have. There are other implementations available, not least the sd_listen_fds() function in libsystemd0, albeit that that is not portable.

Providing this functionality enables things addressed in further issues.