summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-01-24 18:40:28 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2017-01-31 14:40:05 -0500
commit0ae6bab4a97f12a0c93200df36ac1741696eeed5 (patch)
tree5f38d9b1fce3d7f942adcbd5e02b3e50fc84d17a
parentb63c9011c392a3cb0a2e8df82301e5b6002905c9 (diff)
downloadlighttpd1.4-0ae6bab4a97f12a0c93200df36ac1741696eeed5.zip
lighttpd1.4-0ae6bab4a97f12a0c93200df36ac1741696eeed5.tar.gz
[doc] SIGUSR1 doc and lighttpd-angel SIGUSR1
lighttpd-angel: add paranoid check to avoid sending kill(-1, <signal>) as root
-rw-r--r--doc/initscripts.txt13
-rw-r--r--doc/lighttpd-angel.87
-rw-r--r--doc/systemd/lighttpd.service2
-rw-r--r--src/lighttpd-angel.c4
4 files changed, 22 insertions, 4 deletions
diff --git a/doc/initscripts.txt b/doc/initscripts.txt
index 44ea53f..e6104fa 100644
--- a/doc/initscripts.txt
+++ b/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
diff --git a/doc/lighttpd-angel.8 b/doc/lighttpd-angel.8
index ccf394d..dd61b7c 100644
--- a/doc/lighttpd-angel.8
+++ b/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
diff --git a/doc/systemd/lighttpd.service b/doc/systemd/lighttpd.service
index e92b160..6dfe44f 100644
--- a/doc/systemd/lighttpd.service
+++ b/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]
diff --git a/src/lighttpd-angel.c b/src/lighttpd-angel.c
index 4c629a6..2b88e55 100644
--- a/src/lighttpd-angel.c
+++ b/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);