Browse Source

[doc] SIGUSR1 doc and lighttpd-angel SIGUSR1

lighttpd-angel:
  add paranoid check to avoid sending kill(-1, <signal>) as root
personal/stbuehler/mod-csrf
Glenn Strauss 5 years ago
parent
commit
0ae6bab4a9
  1. 13
      doc/initscripts.txt
  2. 7
      doc/lighttpd-angel.8
  3. 2
      doc/systemd/lighttpd.service
  4. 4
      src/lighttpd-angel.c

13
doc/initscripts.txt

@ -1,9 +1,12 @@
* lighttpd responds to the following signals:
SIGINT - shut down gracefully (finish serving existing connections and exit)
SIGTERM - shut down immediately (terminate existing connections and exit)
SIGTERM - shut down immediately (terminate existing connections, then exit)
SIGINT - shut down gracefully (serve existing connections, then exit)
SIGUSR1 - reload gracefully (serve existing connections, then reload config)
SIGHUP - re-open log files (NOTE: does not reload lighttpd configuration)
(Note: SIGUSR1 behavior is available in lighttpd 1.4.46 and later)
* lighttpd graceful restart
@ -11,6 +14,10 @@ https://blog.lighttpd.net/articles/2005/09/02/graceful-restart/
The current recommended way to reload lighttpd config is to gracefully stop
and then to restart lighttpd.
With lighttpd 1.4.46 and later, SIGUSR1 is the recommended method to gracefully
handle configuration reloads and log rotation, though a graceful stop and then
restart of lighttpd is still required for lighttpd configurations which chroot.
* lighttpd initscripts
@ -36,5 +43,7 @@ https://gitweb.gentoo.org/repo/gentoo.git/tree/www-servers/lighttpd/files
openSUSE:
https://build.opensuse.org/package/show/server:http/lighttpd
sample systemd unit script: doc/systemd/lighttpd.service
Additional, updated information may be found at
https://redmine.lighttpd.net/projects/lighttpd/wiki/InstallFromSource

7
doc/lighttpd-angel.8

@ -11,15 +11,18 @@ lighttpd-angel \- monitor/supervise lighttpd daemon
lighttpd-angel will restart lighttpd if lighttpd exits for any reason, other
than by signals sent by lighttpd-angel.
.PP
Send lighttpd-angel SIGTERM to initiate immediate shutdown of lighttpd.
.PP
Send lighttpd-angel SIGINT to initiate graceful shutdown of lighttpd.
.PP
Send lighttpd-angel SIGTERM to initiate shutdown of lighttpd.
Send lighttpd-angel SIGHUP to initiate graceful restart of lighttpd.
.PP
Send lighttpd-angel SIGHUP to initiate restart of lighttpd, reloading config.
Send lighttpd-angel SIGUSR1 to initiate graceful reload of lighttpd config.
.
.SH SEE ALSO
Online Documentation:
https://redmine.lighttpd.net/projects/lighttpd/wiki/InstallFromSource
https://blog.lighttpd.net/articles/2007/09/02/there-is-an-angel-for-lighty/
.
.SH AUTHOR

2
doc/systemd/lighttpd.service

@ -4,8 +4,10 @@ After=network.target
[Service]
Type=simple
PIDFile=/var/run/lighttpd.pid
ExecStartPre=/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf
ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
ExecReload=/bin/kill -USR1 $MAINPID
Restart=on-failure
[Install]

4
src/lighttpd-angel.c

@ -38,12 +38,15 @@ static void sigaction_handler(int sig, siginfo_t *si, void *context) {
switch (sig) {
case SIGINT:
case SIGTERM:
case SIGUSR1:
if (pid <= 0) break;
memcpy(&last_sigterm_info, si, sizeof(*si));
/** forward the sig to the child */
kill(pid, sig);
break;
case SIGHUP: /** do a graceful restart */
if (pid <= 0) break;
memcpy(&last_sighup_info, si, sizeof(*si));
/** do a graceful shutdown on the main process and start a new child */
@ -81,6 +84,7 @@ int main(int argc, char **argv) {
sigaction(SIGINT, &act, NULL);
sigaction(SIGTERM, &act, NULL);
sigaction(SIGUSR1, &act, NULL);
sigaction(SIGHUP, &act, NULL);
sigaction(SIGALRM, &act, NULL);
sigaction(SIGCHLD, &act, NULL);

Loading…
Cancel
Save