[httpd] add systemd service files (#684175, thanks to Jóhann B. Guðmundsson)

jorton jorton at fedoraproject.org
Tue Apr 12 14:39:18 UTC 2011


commit bd3365ed3ec3f117b8c344903c39e55df14aee48
Author: Joe Orton <jorton at redhat.com>
Date:   Tue Apr 12 15:39:15 2011 +0100

    add systemd service files (#684175, thanks to Jóhann B. Guðmundsson)

 httpd.service |   15 +++++++++++++++
 httpd.spec    |   39 ++++++++++++++++++++++++++++++---------
 httpd.sysconf |    8 ++++++++
 3 files changed, 53 insertions(+), 9 deletions(-)
---
diff --git a/httpd.service b/httpd.service
new file mode 100644
index 0000000..35e662c
--- /dev/null
+++ b/httpd.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=The Apache HTTP Server (@NAME@ MPM)
+After=syslog.target network.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/httpd/httpd.pid
+EnvironmentFile=/etc/sysconfig/httpd
+ExecStart=@EXEC@ $OPTIONS -k start
+ExecReload=@EXEC@ $OPTIONS -t
+ExecReload=/bin/kill -HUP $MAINPID
+ExecStop=@EXEC@ $OPTIONS -k stop
+
+[Install]
+WantedBy=multi-user.target
diff --git a/httpd.spec b/httpd.spec
index dc5b03a..c52d717 100644
--- a/httpd.spec
+++ b/httpd.spec
@@ -8,7 +8,7 @@
 Summary: Apache HTTP Server
 Name: httpd
 Version: 2.2.17
-Release: 11%{?dist}
+Release: 12%{?dist}
 URL: http://httpd.apache.org/
 Source0: http://www.apache.org/dist/httpd/httpd-%{version}.tar.bz2
 Source1: index.html
@@ -20,6 +20,7 @@ Source11: ssl.conf
 Source12: welcome.conf
 Source13: manual.conf
 Source14: httpd.tmpfiles
+Source15: httpd.service
 # Documentation
 Source31: httpd.mpm.xml
 Source33: README.confd
@@ -153,6 +154,18 @@ export LYNX_PATH=/usr/bin/links
 function mpmbuild()
 {
 mpm=$1; shift
+
+# Build the systemd file
+sed "s, at NAME@,${mpm},g;s, at EXEC@,%{_sbindir}/httpd.${mpm},g" %{SOURCE15} > httpd-${mpm}.service
+touch -r %{SOURCE15} httpd-${mpm}.service
+
+# Build the man page
+ymdate=`date +'%b %Y'`
+sed "s/@PROGNAME@/httpd.${mpm}/g;s/@DATE@/${ymdate}/g;s/@VERSION@/%{version}/g;s/@MPM@/${mpm}/g;" \
+    < $RPM_SOURCE_DIR/httpd.mpm.xml > httpd.${mpm}.8.xml
+xmlto man httpd.${mpm}.8.xml
+
+# Build the daemon
 mkdir $mpm; pushd $mpm
 ../configure \
  	--prefix=%{_sysconfdir}/httpd \
@@ -199,13 +212,9 @@ for f in %{mpms}; do
    mpmbuild $f --enable-modules=none
 done
 
-# Build the man pages
-ymdate=`date +'%b %Y'`
-for mpm in %{mpms}; do
-    sed "s/@PROGNAME@/httpd.${mpm}/g;s/@DATE@/${ymdate}/g;s/@VERSION@/%{version}/g;s/@MPM@/${mpm}/g;" \
-        < $RPM_SOURCE_DIR/httpd.mpm.xml > httpd.${mpm}.8.xml
-    xmlto man httpd.${mpm}.8.xml
-done
+# Create default/prefork service file for systemd
+sed "s, at NAME@,prefork,g;s, at EXEC@,%{sbindir}/httpd,g" %{SOURCE15} > httpd.service
+touch -r %{SOURCE15} httpd.service
 
 %install
 rm -rf $RPM_BUILD_ROOT
@@ -218,12 +227,19 @@ pushd prefork
 make DESTDIR=$RPM_BUILD_ROOT install
 popd
 
-# install alternative MPMs, and man pages
+# install alternative MPMs; executables, man pages, and systemd service files
+mkdir -p $RPM_BUILD_ROOT/lib/systemd/system
 for f in %{mpms}; do
   install -m 755 ${f}/httpd $RPM_BUILD_ROOT%{_sbindir}/httpd.${f}
   install -m 644 httpd.${f}.8 $RPM_BUILD_ROOT%{_mandir}/man8/httpd.${f}.8
+  install -p -m 644 httpd-${f}.service \
+          $RPM_BUILD_ROOT/lib/systemd/system/httpd-${f}.service
 done
 
+# Default httpd (prefork) service file
+install -p -m 644 httpd.service \
+        $RPM_BUILD_ROOT/lib/systemd/system/httpd.service
+
 # install conf file/directory
 mkdir $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d
 install -m 644 $RPM_SOURCE_DIR/README.confd \
@@ -461,6 +477,8 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man8/*
 %exclude %{_mandir}/man8/apxs.8*
 
+/lib/systemd/system/*.service
+
 %files tools
 %defattr(-,root,root)
 %{_bindir}/*
@@ -491,6 +509,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/httpd/build/*.sh
 
 %changelog
+* Tue Apr 12 2011 Joe Orton <jorton at redhat.com> - 2.2.17-12
+- add systemd service files (#684175, thanks to Jóhann B. Guðmundsson)
+
 * Wed Mar 23 2011 Joe Orton <jorton at redhat.com> - 2.2.17-11
 - minor updates to httpd.conf
 - drop old patches
diff --git a/httpd.sysconf b/httpd.sysconf
index b5ec1e7..b57ac38 100644
--- a/httpd.sysconf
+++ b/httpd.sysconf
@@ -27,4 +27,12 @@
 # To allow a longer delay, set the STOP_TIMEOUT variable.
 #
 #STOP_TIMEOUT=10
+
+#
+# By default, the httpd process will create the file
+# /var/run/httpd/httpd.pid in which it records its process
+# identification number when it starts.  If an alternate location is
+# specified in httpd.conf (via the PidFile directive), the new
+# location needs to be reported in the PIDFILE.
 #
+#PIDFILE=/var/run/httpd/httpd.pid


More information about the scm-commits mailing list