Hi, Am rebuilding httpd from scratch to enable http2 and minimize extra modules on Cent Os 8. Am having trouble understanding the spec file [0] and systemd initialization [1][2][3] (these are very similar to those extracted from [4]). Why are 3 scripts needed to start the service and why is a pid setting not needed as used in the httpd.service file at [5]? Benson [0] https://src.fedoraproject.org/rpms/httpd/blob/HEAD/f/httpd.spec [1] https://src.fedoraproject.org/rpms/httpd/tree/f31 [2] https://src.fedoraproject.org/rpms/httpd/blob/f31/f/httpd.service [3] https://src.fedoraproject.org/rpms/httpd/blob/f31/f/httpd-init.service [4] http://vault.centos.org/8.0.1905/AppStream/Source/SPackages/httpd-2.4.37-12.module_el8.0.0+185+5908b0db.src.rpm [5] https://blacksaildivision.com/how-to-install-apache-httpd-on-centos
On Fri, Jan 10, 2020 at 06:18:07PM +0300, Benson Muite wrote:> Am rebuilding httpd from scratch to enable http2 and minimize extra modules > on Cent Os 8. Am having trouble understanding the spec file [0] and systemd > initialization [1][2][3] (these are very similar to those extracted from > [4]). Why are 3 scripts needed to start the service and why is a pid setting > not needed as used in the httpd.service file at [5]?The httpd-init.service handles some ssl cert generation on the first time a system runs, so httpd doesn't just die because there were missing SSL certs. They're self-signed. The httpd.socket unit lets you have systemd listen on port 80 and only start httpd if someone connects. THat's not a standard use, though. The httpd.service in the Fedora/CentOS systemd service unit uses Type=notify instead of Type=forking. While it's possible for systemd to keep track of all the subprocesses of a forking daemon, its difficult to determine if the service is "started". It uses the Pid file for that. With Type=notify, the daemon will send a notification back to systemd via sd_notify() when it is up, which makes it easier for systemd to know when a service has started, and start any dependencies or established that a target has been reached. You need a service that supports Type=notify, which httpd does. -- Jonathan Billings <billings at negate.org>
On 1/10/20 6:34 PM, Jonathan Billings wrote:> On Fri, Jan 10, 2020 at 06:18:07PM +0300, Benson Muite wrote: >> Am rebuilding httpd from scratch to enable http2 and minimize extra modules >> on Cent Os 8. Am having trouble understanding the spec file [0] and systemd >> initialization [1][2][3] (these are very similar to those extracted from >> [4]). Why are 3 scripts needed to start the service and why is a pid setting >> not needed as used in the httpd.service file at [5]? > The httpd-init.service handles some ssl cert generation on the first > time a system runs, so httpd doesn't just die because there were > missing SSL certs. They're self-signed. The httpd.socket unit lets > you have systemd listen on port 80 and only start httpd if someone > connects. THat's not a standard use, though. > > The httpd.service in the Fedora/CentOS systemd service unit uses > Type=notify instead of Type=forking. While it's possible for systemd > to keep track of all the subprocesses of a forking daemon, its > difficult to determine if the service is "started". It uses the Pid > file for that. > > With Type=notify, the daemon will send a notification back to systemd > via sd_notify() when it is up, which makes it easier for systemd to > know when a service has started, and start any dependencies or > established that a target has been reached. You need a service that > supports Type=notify, which httpd does.Thanks. Seems like need to use development version [0] or use patch [1] [0] https://svn.apache.org/viewvc/httpd/httpd/trunk/modules/arch/unix/mod_systemd.c?revision=1840555&view=markup [1] https://src.fedoraproject.org/rpms/httpd/blob/master/f/httpd-2.4.33-systemd.patch>