Project

General

Profile

[Solved] Catching lighttpd signals

Added by paras about 15 years ago

Hi,

If I use an external program like "rotatelogs" that comes with apache for logrotation of lighttpd logs through piping ,will I be able to catch the signal given to lighttpd when it is stopped/reload in the rotatelogs utility ? I tried using the signal(SIGTERM,func) by including "signal.h" in rotatelogs but it doesn't seem to catch it . Is it possible though ? It works for apache .

Thank you.

-Paras


Replies (2)

RE: Catching lighttpd signals - Added by sasho about 15 years ago

Try with SIGHUP.

RE: Catching lighttpd signals - Added by ycheng about 15 years ago

Do NOT handle any signal yourself, unless you know exactly what you are doing and how lighttpd deals with signals.
If what you do is just rotate log files. you may use this hook:
handle_sighup
called if a SIGHUP is received (cycling logfiles, ...)

Here is a domo

int mod_proxy_plugin_init(plugin *p)
{
p->version = LIGHTTPD_VERSION_ID;
p->name = buffer_init_string("proxy");
p->data = NULL;
...
p->handle_sighup = mod_proxy_handle_sighup; // this is what you want
return 0;
}
static handler_t mod_proxy_handle_sighup(server *srv, void *p_d) {
plugin_data *p = p_d;
... // rotating
}

And you can send SIGHUP to lighttpd. lighttpd will catch that and call your "mod_proxy_handle_sighup()", every plugins' handle_sighup hook exactly.

    (1-2/2)