49

My server (ubuntu 8.04) LAMP running drupal 6, when there is high traffic, it stops serving pages. A restart of apache2 will not work, so I have to restart the service.

I found this message in the apache2 error.log

[notice] caught SIGWINCH, shutting down gracefully

Also I notice that the process id of the apache2, was around 12000 when apache stops responding.

Update

The caught SIGWINCH, as you point out, is a notice of the apache service restarting. I played around with the max clients and keep alive. I set the MaxClients too low so I got a "server reached MaxClients setting, consider raising the MaxClients setting" error, but fixed that.

Regarding the PID, my installation has prefork module installed, so after MaxRequestPerChild is reached, it recycles the child process. That is why the PID is rising periodically. Still haven't figured out why after a while apache stops responding.

In the mean time will try to rise the MaxRequestPerChild so the PID dosen't reach PID max that fast. Current limit is 32768 (which is standard for new debian and ubuntu installations).

Here is more from the log:

[Fri Apr 24 01:48:56 2009] [notice] caught SIGWINCH, shutting down gracefully

[Fri Apr 24 01:50:07 2009] [notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured -- resuming normal operations

[Fri Apr 24 17:13:35 2009] [error] [client 195.70.62.131] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)

[Fri Apr 24 17:36:00 2009] [error] [client 212.188.33.4] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)

[Sat Apr 25 20:05:07 2009] [error] [client 84.243.222.12] Invalid URI in request GET HTTP/1.1 HTTP/1.1

[Sat Apr 25 20:05:12 2009] [error] [client 84.243.222.12] script not found or unable to stat: /usr/lib/cgi-bin/twiki

[Sat Apr 25 20:05:12 2009] [error] [client 84.243.222.12] script not found or unable to stat: /usr/lib/cgi-bin/wiki

[Sat Apr 25 20:05:12 2009] [error] [client 84.243.222.12] script not found or unable to stat: /usr/lib/cgi-bin/wikis

[Sat Apr 25 21:46:46 2009] [error] [client 211.68.23.167] Invalid URI in request GET HTTP/1.1 HTTP/1.1

[Sun Apr 26 06:13:47 2009] [error] [client 86.39.154.89] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)

[Sun Apr 26 06:53:07 2009] [notice] Graceful restart requested, doing restart

Daniel Heilper
  • 1,182
  • 2
  • 17
  • 34
Geries
  • 21
  • 1
  • 4
  • 9

5 Answers5

60

SIGWINCH

As a matter of fact, @Stefano is right: SIGWINCH means SIGNAL WINDOWS CHANGE and is sent automatically when a terminal detects a change in it's windows size to allow for a redraw.

SIGWINCH for apache2

But unfortunately apache2 process poorly misuses this signal (in the way they divert its first meaning), but for their defense, they seems not to have a choice and had to resort to this due to a lack of signal (see bug report). One of their assumption is that apache2 process is always in background. So @mikl is also perfectly right also.

So, what to check ?

  • any automatic reason to restart gracefully apache2 (cron services, apt-get installations of related services...)
  • otherwise, do you run apache2 in foreground in an open tty ? If yes, this is not recommended (alas), and you'll probably easily hit this SIGWINCH gracefull shutdown quite easily when resizing your controlling terminal.
vaab
  • 9,685
  • 7
  • 55
  • 60
20

uh? if I remember correctly, SIGWINCH is a signal that get sent to a terminal application when the size of the terminal window changes (so that the application can resize itself). Typically used by ncurses applications.

This is very strange. Does this info gives you additional hints ?

Stefano Borini
  • 138,652
  • 96
  • 297
  • 431
  • Well 10 seconds after the "[notice] caught SIGWINCH, shutting down gracefully. There is a "[notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured -- resuming normal operations" – Geries Apr 23 '09 at 12:17
  • 1
    This as designed, see https://bz.apache.org/bugzilla/show_bug.cgi?id=50669 – serv-inc Jul 24 '16 at 12:56
  • 4
    @serv-inc Right, it’s a terrible design. – Konrad Rudolph Feb 09 '18 at 18:02
17

Well, SIGWINCH is used in some situations when starting and stopping Apache on Ubuntu. If I do sudo apache2ctl graceful-stop on my Ubuntu 8.10 server, I get this in my log:

[Fri Apr 24 22:41:15 2009] [notice] caught SIGWINCH, shutting down gracefully

As I remember it, SIGWINCH is also used by some services that need to restart Apache when rotating logs, nightly jobs, etc.

That doesn't explain the problem you're currently having, but I think it might be something else running on your server that's restarting Apache – or it might not be related to your problem at all.

Try posting more of the logfile if you can, it'll be a lot easier to analyse :)

mikl
  • 23,749
  • 20
  • 68
  • 89
  • Yeah your right on the sigwinch, added more on the log. Thanks. – Geries Apr 29 '09 at 15:14
  • Well, there's nothing in that log dump to indicate what the real problem is. How's your memory status look when the problem occurs? The tweaking of MaxClients can be tricky – if you set it to high, Apache will eat all available memory and go into complete deadlock. Also, what Apache module do you have enabled? – mikl May 02 '09 at 09:54
  • I have 1GB memory and there like 600MB free when the problem occurs. The enabled modules are rewrite, php5, mime and cgi. Maybe Apache is not the problem, I will try to install of Debian a move the site there, sometimes is "cheaper" just to start with a clean sleeve. Thanks – Geries May 02 '09 at 12:22
  • for me, my hosts file had unknown ip which pointing to server hostname set by the host when configuring the server. after i removed that, this sigwinch error dissapear from error log. – Janaka R Rajapaksha Dec 01 '14 at 09:01
  • This happens often when running apache in an interactive Docker container. Resize the terminal window and apache shuts down...nice to finally know why. – Shane May 19 '16 at 21:03
6

On Apache, SIGWINCH is the Graceful Stop signal. Note that this is different than SIGUSR1, which is the Graceful Restart signal.

Unfortunately, we need more information to tell you why Apache is gracefully stopping.

Powerlord
  • 87,612
  • 17
  • 125
  • 175
0

I had this error while trying to run php:7.4-apache image in a K8s cluster, and wanted to share my solution here.

My particular docker image had STOPSIGNAL SIGWINCH in the Dockerfile somewhere. STOPSIGNAL defines which signal will be sent to the process when docker stop command is run.

This meant whenever my Kubernetes Liveliness and Readiness probes failed and wanted to restart the container I'd have the SIGWINCH error when the container had just started. If the apache2 won't run due to some config error, Readiness Probes will restart the container, giving you SIGWINCH error, and it's not the root cause.


Running apache2 vs apache2ctl

When I had CMD apache2 -DFOREGROUND in my docker file I got this error:

Config variable ${APACHE_RUN_DIR} is not defined
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

Turns out DefaultRuntimeDir is defined at /etc/apache2/envvars and it must be loaded before apache2 runs. I noticed that running the process with apache2 does not load this file.

My solution was to use apache2ctl that was provided with my docker image. Final dockerfile looks like this: CMD ["/usr/sbin/apache2ctl", "-DFOREGROUND"].