Re: [modwsgi] Apache2 reload causes HTTP 503

112 views
Skip to first unread message

Graham Dumpleton

unread,
Nov 16, 2012, 5:58:47 PM11/16/12
to modwsgi
That can happen momentarily when a graceful restart of Apache is done as Apache allows the child worker processes which are proxying requests to mod_wgsi daemon processes to hang around until all requests on a HTTP connection are handled.

It comes about because the socket path has a generation number in it. Every time you restart Apache the generation number goes up one. Thus an older child worker created for a prior generation will be trying to connect to a socket path which no longer exists, because the mod_wsgi daemon processes for that older generation have been killed and replaced with those corresponding to next generation.

This is a self protection mechanism to ensure that old child worker process that still haven't been killed and which are running against Apache configuration for an older generation, are not able to connect to daemon process running with a newer Apache configuration. Allowing them to would produce undefined results, errors or potential security issues.

Thus, so long as transitory, it is normal.

Can you confirm whether do a graceful restart of Apache?

It could also happen with a normal restart, but you would have to be quite lucky for it to happen in that case.

Graham


On 17 November 2012 01:49, Sebastian Dahlgren <sebastian...@gmail.com> wrote:
Hi!

I have a mod_wsgi setup with Apache2 and Flask. If I have an active connection to the Apache2 server from a HTTP client and I reload the Apache2, the client will get a HTTP 503 back. The Apache error log says the following:

[Fri Nov 16 14:27:30 2012] [error] [client 213.115.37.68] (2)No such file or directory: mod_wsgi (pid=19720): Unable to connect to WSGI daemon process 'upload_handler' on '/etc/apache2/run/wsgi.18907.3.1.sock' after multiple attempts.

This is what my Apache config looks like:

<VirtualHost *:443>
    ServerAdmin m...@email.com
    ServerName my.example.com

    WSGIDaemonProcess upload_handler user=www-data group=www-data threads=5 processes=4
    WSGIScriptAlias / /usr/local/uploader/uploader.wsgi

    <Directory /usr/local/uploader>
        WSGIProcessGroup upload_handler
        WSGIApplicationGroup %{GLOBAL}
        WSGIScriptReloading Off
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

I have Googled and read the mod_wsgi documentation to find an answer, but I can't find anything that matches. Does anyone here have a clue what the problem might be?

Cheers

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To view this discussion on the web visit https://groups.google.com/d/msg/modwsgi/-/VuXuNqq6leEJ.
To post to this group, send email to mod...@googlegroups.com.
To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.

Sebastian Dahlgren

unread,
Nov 19, 2012, 9:55:08 AM11/19/12
to mod...@googlegroups.com
Thank you for the explaination. We are doing a graceful restart of Apache.

/Sebastian
Reply all
Reply to author
Forward
0 new messages