Restarting or stopping apache results in waiting forever

Posted by steko on Server Fault See other posts from Server Fault or by steko
Published on 2012-11-14T12:30:52Z Indexed on 2012/11/14 23:02 UTC
Read the original article Hit count: 207

Filed under:
|

I have two simple WSGI apps running on top of mod_wsgi and apache2 on a test development server. There is no mod_python on this machine.

The WSGI configuration is as follows

    WSGIDaemonProcess tops stack-size=524288 maximum-requests=5
    WSGIScriptAlias /tops /home/ubuntu/tops-cloud/tops.wsgi

    <Directory /home/ubuntu/tops-cloud>
            WSGIProcessGroup tops
            WSGIApplicationGroup %{GLOBAL}
            Order deny,allow
            Allow from all
    </Directory>


    WSGIDaemonProcess flaskal maximum-requests=5
    WSGIScriptAlias /c14 /home/ubuntu/c14/flaskal/flaskal.wsgi

    <Directory /home/ubuntu/c14/flaskal>
            WSGIProcessGroup flaskal
            WSGIApplicationGroup %{GLOBAL}
            Order deny,allow
            Allow from all
    </Directory>

If I make changes to the app, I need to restart the web server, so I would expect that a simple sudo service apache2 restart does what I need. Same goes for any changes to the config (e.g. number of maximum requests, etc).

Instead, it never ends "waiting", like this:

$ sudo service apache2 restart
 * Restarting web server apache2
... waiting ..................................................

until I just do CTRL-C. At that point, the only way to resume a working server is to kill the process and restart it, not very convenient. The same happens with the stop command.

The error logs at the "debug" level show the following lines after a failed restart

[Wed Nov 14 21:55:19 2012] [notice] caught SIGTERM, shutting down
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Shutdown requested 'tops'.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Stopping process 'tops'.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Destroying interpreters.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Cleanup interpreter ''.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Terminating Python.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Shutdown requested 'flaskal'.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Stopping process 'flaskal'.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Destroying interpreters.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Cleanup interpreter ''.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Terminating Python.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Python has shutdown.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Python has shutdown.

If I then try to restart again (with the process still running), I get the following error:

 * Restarting web server apache2                                                                                                            (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

Unfortunately the Apache error log doesn't have anything.

When apache2 is running properly, both apps work without any problem.

© Server Fault or respective owner

Related posts about apache2

Related posts about mod-wsgi