You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jk...@apache.org on 2014/08/18 12:48:42 UTC
svn commit: r1618579 - in /httpd/httpd/trunk:
docs/log-message-tags/next-number docs/manual/mod/mod_systemd.xml
modules/arch/unix/mod_systemd.c
Author: jkaluza
Date: Mon Aug 18 10:48:41 2014
New Revision: 1618579
URL: http://svn.apache.org/r1618579
Log:
mod_systemd: Add IdleShutdown - number of seconds in idle-state after which
httpd is shutdown. This is useful in a combination with socket activation.
Add mod_systemd documentation.
Added:
httpd/httpd/trunk/docs/manual/mod/mod_systemd.xml (with props)
Modified:
httpd/httpd/trunk/docs/log-message-tags/next-number
httpd/httpd/trunk/modules/arch/unix/mod_systemd.c
Modified: httpd/httpd/trunk/docs/log-message-tags/next-number
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1618579&r1=1618578&r2=1618579&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/log-message-tags/next-number (original)
+++ httpd/httpd/trunk/docs/log-message-tags/next-number Mon Aug 18 10:48:41 2014
@@ -1 +1 @@
-2804
+2805
Added: httpd/httpd/trunk/docs/manual/mod/mod_systemd.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_systemd.xml?rev=1618579&view=auto
==============================================================================
Binary file - no diff available.
Propchange: httpd/httpd/trunk/docs/manual/mod/mod_systemd.xml
------------------------------------------------------------------------------
svn:mime-type = application/xml
Modified: httpd/httpd/trunk/modules/arch/unix/mod_systemd.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/arch/unix/mod_systemd.c?rev=1618579&r1=1618578&r2=1618579&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/arch/unix/mod_systemd.c (original)
+++ httpd/httpd/trunk/modules/arch/unix/mod_systemd.c Mon Aug 18 10:48:41 2014
@@ -34,15 +34,21 @@
#include <unistd.h>
#endif
+static int shutdown_timer = 0;
+static int shutdown_counter = 0;
+static unsigned long bytes_served;
+static pid_t mainpid;
+
static int systemd_pre_mpm(apr_pool_t *p, ap_scoreboard_e sb_type)
{
int rv;
ap_extended_status = 1;
+ mainpid = getpid();
rv = sd_notifyf(0, "READY=1\n"
"STATUS=Processing requests...\n"
- "MAINPID=%" APR_PID_T_FMT, getpid());
+ "MAINPID=%" APR_PID_T_FMT, mainpid);
if (rv < 0) {
ap_log_perror(APLOG_MARK, APLOG_ERR, 0, p, APLOGNO(02395)
"sd_notifyf returned an error %d", rv);
@@ -77,6 +83,26 @@ static int systemd_monitor(apr_pool_t *p
"sd_notifyf returned an error %d", rv);
}
+ /* Shutdown httpd when nothing is sent for shutdown_timer seconds. */
+ if (sload.bytes_served == bytes_served) {
+ shutdown_counter += 10;
+ if (shutdown_timer > 0 && shutdown_counter >= shutdown_timer) {
+ rv = sd_notifyf(0, "READY=1\n"
+ "STATUS=Stopped as result of IdleShutdown "
+ "timeout.");
+ if (rv < 0) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(02804)
+ "sd_notifyf returned an error %d", rv);
+ }
+ kill(mainpid, SIGWINCH);
+ }
+ }
+ else {
+ shutdown_counter = 0;
+ }
+
+ bytes_served = sload.bytes_served;
+
return DECLINED;
}
@@ -88,12 +114,31 @@ static void systemd_register_hooks(apr_p
ap_hook_monitor(systemd_monitor, NULL, NULL, APR_HOOK_MIDDLE);
}
+static const char *set_shutdown_timer(cmd_parms *cmd, void *dummy,
+ const char *arg)
+{
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+ if (err != NULL) {
+ return err;
+ }
+
+ shutdown_timer = atoi(arg);
+ return NULL;
+}
+
+static const command_rec systemd_cmds[] =
+{
+AP_INIT_TAKE1("IdleShutdown", set_shutdown_timer, NULL, RSRC_CONF,
+ "Number of seconds in idle-state after which httpd is shutdown"),
+ {NULL}
+};
+
AP_DECLARE_MODULE(systemd) = {
STANDARD20_MODULE_STUFF,
NULL,
NULL,
NULL,
NULL,
- NULL,
+ systemd_cmds,
systemd_register_hooks,
};
Re: svn commit: r1618579 - in /httpd/httpd/trunk: docs/log-message-tags/next-number
docs/manual/mod/mod_systemd.xml modules/arch/unix/mod_systemd.c
Posted by Jan Kaluža <jk...@redhat.com>.
On 08/18/2014 02:23 PM, Ruediger Pluem wrote:
>
>
> jkaluza@apache.org wrote:
>> Author: jkaluza
>> Date: Mon Aug 18 10:48:41 2014
>> New Revision: 1618579
>>
>> URL: http://svn.apache.org/r1618579
>> Log:
>> mod_systemd: Add IdleShutdown - number of seconds in idle-state after which
>> httpd is shutdown. This is useful in a combination with socket activation.
>> Add mod_systemd documentation.
>>
>> Added:
>> httpd/httpd/trunk/docs/manual/mod/mod_systemd.xml (with props)
>> Modified:
>> httpd/httpd/trunk/docs/log-message-tags/next-number
>> httpd/httpd/trunk/modules/arch/unix/mod_systemd.c
>>
>> Modified: httpd/httpd/trunk/docs/log-message-tags/next-number
>> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1618579&r1=1618578&r2=1618579&view=diff
>> ==============================================================================
>> --- httpd/httpd/trunk/docs/log-message-tags/next-number (original)
>> +++ httpd/httpd/trunk/docs/log-message-tags/next-number Mon Aug 18 10:48:41 2014
>> @@ -1 +1 @@
>> -2804
>> +2805
>>
>> Added: httpd/httpd/trunk/docs/manual/mod/mod_systemd.xml
>> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_systemd.xml?rev=1618579&view=auto
>> ==============================================================================
>> Binary file - no diff available.
>>
>> Propchange: httpd/httpd/trunk/docs/manual/mod/mod_systemd.xml
>> ------------------------------------------------------------------------------
>> svn:mime-type = application/xml
>>
>
> Why is this a binary file and no text file?
Hm, it seems that subversion treats XML as application/xml by default in
Fedora. I've fixed that in r1618595.
Jan Kaluza
> Regards
>
> Rüdiger
>
Re: svn commit: r1618579 - in /httpd/httpd/trunk: docs/log-message-tags/next-number
docs/manual/mod/mod_systemd.xml modules/arch/unix/mod_systemd.c
Posted by Ruediger Pluem <rp...@apache.org>.
jkaluza@apache.org wrote:
> Author: jkaluza
> Date: Mon Aug 18 10:48:41 2014
> New Revision: 1618579
>
> URL: http://svn.apache.org/r1618579
> Log:
> mod_systemd: Add IdleShutdown - number of seconds in idle-state after which
> httpd is shutdown. This is useful in a combination with socket activation.
> Add mod_systemd documentation.
>
> Added:
> httpd/httpd/trunk/docs/manual/mod/mod_systemd.xml (with props)
> Modified:
> httpd/httpd/trunk/docs/log-message-tags/next-number
> httpd/httpd/trunk/modules/arch/unix/mod_systemd.c
>
> Modified: httpd/httpd/trunk/docs/log-message-tags/next-number
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1618579&r1=1618578&r2=1618579&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/docs/log-message-tags/next-number (original)
> +++ httpd/httpd/trunk/docs/log-message-tags/next-number Mon Aug 18 10:48:41 2014
> @@ -1 +1 @@
> -2804
> +2805
>
> Added: httpd/httpd/trunk/docs/manual/mod/mod_systemd.xml
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_systemd.xml?rev=1618579&view=auto
> ==============================================================================
> Binary file - no diff available.
>
> Propchange: httpd/httpd/trunk/docs/manual/mod/mod_systemd.xml
> ------------------------------------------------------------------------------
> svn:mime-type = application/xml
>
Why is this a binary file and no text file?
Regards
Rüdiger