diff options
| -rw-r--r-- | 00-systemd.conf | 2 | ||||
| -rw-r--r-- | httpd-2.4.3-mod_systemd.patch | 175 | ||||
| -rw-r--r-- | httpd.spec | 14 | 
3 files changed, 189 insertions, 2 deletions
diff --git a/00-systemd.conf b/00-systemd.conf new file mode 100644 index 0000000..b208c97 --- /dev/null +++ b/00-systemd.conf @@ -0,0 +1,2 @@ +# This file configures systemd module: +LoadModule systemd_module modules/mod_systemd.so diff --git a/httpd-2.4.3-mod_systemd.patch b/httpd-2.4.3-mod_systemd.patch new file mode 100644 index 0000000..3b279b6 --- /dev/null +++ b/httpd-2.4.3-mod_systemd.patch @@ -0,0 +1,175 @@ +diff --git a/modules/arch/unix/mod_systemd.c b/modules/arch/unix/mod_systemd.c +new file mode 100644 +index 0000000..40dca79 +--- /dev/null ++++ b/modules/arch/unix/mod_systemd.c +@@ -0,0 +1,145 @@ ++/* Licensed to the Apache Software Foundation (ASF) under one or more ++ * contributor license agreements.  See the NOTICE file distributed with ++ * this work for additional information regarding copyright ownership. ++ * The ASF licenses this file to You under the Apache License, Version 2.0 ++ * (the "License"); you may not use this file except in compliance with ++ * the License.  You may obtain a copy of the License at ++ * ++ *     http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ *  ++ */ ++ ++#include <stdint.h> ++#include <ap_config.h> ++#include "ap_mpm.h" ++#include <http_core.h> ++#include <http_log.h> ++#include <apr_version.h> ++#include <apr_pools.h> ++#include <apr_strings.h> ++#include "unixd.h" ++#include "scoreboard.h" ++#include "mpm_common.h" ++ ++#include "systemd/sd-daemon.h" ++ ++#if APR_HAVE_UNISTD_H ++#include <unistd.h> ++#endif ++ ++#define KBYTE 1024 ++ ++static pid_t pid;	/* PID of the main httpd instance */ ++static int server_limit, thread_limit, threads_per_child, max_servers; ++static time_t last_update_time; ++static unsigned long last_update_access; ++static unsigned long last_update_kbytes; ++ ++static int systemd_post_config(apr_pool_t *p, apr_pool_t *plog, ++                            apr_pool_t *ptemp, server_rec *s) ++{ ++    int rv; ++    last_update_time = time(0); ++ ++    ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &thread_limit); ++    ap_mpm_query(AP_MPMQ_HARD_LIMIT_DAEMONS, &server_limit); ++    ap_mpm_query(AP_MPMQ_MAX_THREADS, &threads_per_child); ++    /* work around buggy MPMs */ ++    if (threads_per_child == 0) ++        threads_per_child = 1; ++    ap_mpm_query(AP_MPMQ_MAX_DAEMONS, &max_servers); ++ ++    /* For every MPM, there is already the main process ready in ++    * AP_SQ_MS_CREATE_CONFIG state. */ ++    if (pid == 0 && ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_CONFIG) ++    { ++        pid = getpid(); ++ ++        rv = sd_notifyf(0, "READY=1\n" ++                "STATUS=Processing requests...\n" ++                "MAINPID=%lu", ++                (unsigned long) pid); ++        if (rv < 0) ++        { ++            ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00000) ++                "sd_notifyf returned an error %d", rv); ++        } ++    } ++    return OK; ++} ++ ++static int systemd_monitor(apr_pool_t *p, server_rec *s) { ++    int i, j, res, rv; ++    process_score *ps_record; ++    worker_score *ws_record; ++    unsigned long access = 0; ++    unsigned long bytes = 0; ++    unsigned long kbytes = 0; ++ ++    time_t now = time(0); ++    time_t elapsed = now - last_update_time; ++ ++    for (i = 0; i < server_limit; ++i) { ++        ps_record = ap_get_scoreboard_process(i); ++        for (j = 0; j < thread_limit; ++j) { ++            ws_record = ap_get_scoreboard_worker_from_indexes(i, j); ++            if (ap_extended_status && !ps_record->quiescing && ps_record->pid) { ++                res = ws_record->status; ++                if (ws_record->access_count != 0 ||  ++                    (res != SERVER_READY && res != SERVER_DEAD)) { ++                    access += ws_record->access_count; ++                    bytes += ws_record->bytes_served; ++                    if (bytes >= KBYTE) { ++                        kbytes += (bytes >> 10); ++                        bytes = bytes & 0x3ff; ++                    } ++                } ++            } ++        } ++    } ++ ++    char bps[5]; ++    apr_strfsize((unsigned long)(KBYTE *(float) (kbytes - last_update_kbytes) ++                        / (float) elapsed), bps); ++ ++    rv = sd_notifyf(0, "READY=1\n" ++                "STATUS=Total requests: %lu; Current requests/sec: %.3g; " ++                "Current traffic: %sB/sec\n", access, ++                ((float)access - last_update_access) / (float) elapsed, bps); ++    if (rv < 0) ++    { ++        ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00000) ++            "sd_notifyf returned an error %d", rv); ++    } ++ ++    last_update_access = access; ++    last_update_kbytes = kbytes; ++    last_update_time = now; ++ ++    return DECLINED; ++} ++ ++static void systemd_register_hooks(apr_pool_t *p) ++{ ++    /* We know the PID in this hook ... */ ++    ap_hook_post_config(systemd_post_config, NULL, NULL, APR_HOOK_LAST); ++    /* Used to update httpd's status line using sd_notifyf */ ++    ap_hook_monitor(systemd_monitor, NULL, NULL, APR_HOOK_MIDDLE); ++} ++ ++module AP_MODULE_DECLARE_DATA systemd_module = ++{ ++    STANDARD20_MODULE_STUFF, ++    NULL, ++    NULL, ++    NULL, ++    NULL, ++    NULL, ++    systemd_register_hooks, ++}; +diff --git a/modules/arch/unix/config5.m4 b/modules/arch/unix/config5.m4 +index 77027a8..4fd9799 100644 +--- a/modules/arch/unix/config5.m4 ++++ b/modules/arch/unix/config5.m4 +@@ -18,6 +18,19 @@ APACHE_MODULE(privileges, Per-virtualhost Unix UserIDs and enhanced security for +   fi + ]) +  ++ ++APACHE_MODULE(systemd, Systemd support, , , $unixd_mods_enabled, [ ++  AC_CHECK_LIB(systemd-daemon, sd_notify, SYSTEMD_LIBS="-lsystemd-daemon") ++  AC_CHECK_HEADERS(systemd/sd-daemon.h, [ap_HAVE_SD_DAEMON_H="yes"], [ap_HAVE_SD_DAEMON_H="no"]) ++  if test $ap_HAVE_SD_DAEMON_H = "no" || test -z "${LUA_LIBS}"; then ++    AC_MSG_WARN([Your system does not support systemd.]) ++    enable_systemd="no" ++  else ++    APR_ADDTO(MOD_SYSTEMD_LDADD, [$SYSTEMD_LIBS]) ++    enable_systemd="yes" ++  fi ++]) ++ + APR_ADDTO(INCLUDES, [-I\$(top_srcdir)/$modpath_current]) +  + APACHE_MODPATH_FINISH @@ -8,7 +8,7 @@  Summary: Apache HTTP Server  Name: httpd  Version: 2.4.3 -Release: 2%{?dist} +Release: 3%{?dist}  URL: http://httpd.apache.org/  Source0: http://www.apache.org/dist/httpd/httpd-%{version}.tar.bz2  Source1: index.html @@ -33,6 +33,7 @@ Source20: userdir.conf  Source21: ssl.conf  Source22: welcome.conf  Source23: manual.conf +Source24: 00-systemd.conf  # Documentation  Source30: README.confd  # build/scripts patches @@ -48,6 +49,7 @@ Patch25: httpd-2.4.1-selinux.patch  Patch26: httpd-2.4.2-r1337344+.patch  Patch27: httpd-2.4.2-icons.patch  Patch28: httpd-2.4.2-r1332643+.patch +Patch29: httpd-2.4.3-mod_systemd.patch  # Bug fixes  Patch50: httpd-2.4.2-r1374214+.patch  License: ASL 2.0 @@ -56,6 +58,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root  BuildRequires: autoconf, perl, pkgconfig, findutils, xmlto  BuildRequires: zlib-devel, libselinux-devel, lua-devel  BuildRequires: apr-devel >= 1.4.0, apr-util-devel >= 1.2.0, pcre-devel >= 5.0 +BuildRequires: systemd-devel  Requires: /etc/mime.types, system-logos >= 7.92.1-1  Obsoletes: httpd-suexec  Provides: webserver @@ -157,6 +160,7 @@ authentication to the Apache HTTP Server.  %patch26 -p1 -b .r1337344+  %patch27 -p1 -b .icons  %patch28 -p1 -b .r1332643+ +%patch29 -p1 -b .systemd  %patch50 -p1 -b .r1374214+ @@ -249,7 +253,7 @@ install -m 644 $RPM_SOURCE_DIR/README.confd \      $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/README  for f in 00-base.conf 00-mpm.conf 00-lua.conf 01-cgi.conf 00-dav.conf \           00-proxy.conf 00-ssl.conf 01-ldap.conf 00-proxyhtml.conf \ -         01-ldap.conf; do +         01-ldap.conf 00-systemd.conf; do    install -m 644 -p $RPM_SOURCE_DIR/$f \          $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.modules.d/$f  done @@ -574,6 +578,12 @@ rm -rf $RPM_BUILD_ROOT  %{_sysconfdir}/rpm/macros.httpd  %changelog +* Wed Sep 12 2012 Remi Collet <RPMS@FamilleCollet.com> - 2.4.3-3 +- sync with rawhide, rebuild for remi repo + +* Fri Sep 07 2012 Jan Kaluza <jkaluza@redhat.com> - 2.4.3-3 +- adding mod_systemd to integrate with systemd better +  * Tue Aug 21 2012 Remi Collet <RPMS@FamilleCollet.com> - 2.4.3-2  - sync with rawhide, rebuild for remi repo  | 
